我有QTreeView水平滚动条的问题,它没有出现.我已将水平滚动条策略设置为ScrollBarAsNeeded,但如果需要则不会显示.尝试将扩展和折叠信号连接到插槽:
connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex)));
connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex)));
Run Code Online (Sandbox Code Playgroud)
该插槽由一行代码组成:
update_scroll_area(const QModelIndex& i)
{
resizeColumnToContents(i.column());
}
Run Code Online (Sandbox Code Playgroud)
这使滚动条工作,但只有在我展开/折叠树视图项时.
我需要"每次"工作水平滚动条,从启动应用程序到结束.怎么组织起来?
谢谢.
我已经学习了Qt的基础知识,现在对这个漂亮的库的深度感兴趣.请帮我理解:
return app.exec();是什么意思?什么是执行exec()方法呢?谢谢.
我有这个代码的问题:
struct document_type_content
{
long long m_ID;
QString m_type_name;
};
std::vector<QString> document_type::get_fields_by_name(e_doc_type) const
{
std::vector<QString> tmp;
std::vector<document_type_content*>::iterator it = m_table_data.begin(),
it_end = m_table_data.end();
for ( ; it != it_end; ++it) {
document_type_content* cnt = *it;
tmp.push_back(cnt->m_type_name);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在为项目使用QtCreator,它给了我以下错误(对于行,初始化迭代器的行):
error: conversion from '__gnu_cxx::__normal_iterator<document_type_content* const*, std::vector<document_type_content*, std::allocator<document_type_content*> > >' to non-scalar type '__gnu_cxx::__normal_iterator<document_type_content**, std::vector<document_type_content*, std::allocator<document_type_content*> > >' requested
Run Code Online (Sandbox Code Playgroud)
这可能是一个简单的问题,无论如何,不是我:).
非常感谢提前.