小编Deh*_*zer的帖子

QTreeView水平滚动条问题

我有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 horizontal-scrolling qtreeview

7
推荐指数
2
解决办法
1万
查看次数

常见的Qt问题

我已经学习了Qt的基础知识,现在对这个漂亮的库的深度感兴趣.请帮我理解:

  1. 所有类都是从QObject派生的吗?
  2. 为什么可以在QWidget(和派生类)上绘制?
  3. 这条线return app.exec();是什么意思?什么是执行exec()方法呢?
  4. 虚拟插槽吗?和虚拟信号

谢谢.

qt qt4

4
推荐指数
1
解决办法
4172
查看次数

包含用户定义类型指针的C++向量

我有这个代码的问题:

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)

这可能是一个简单的问题,无论如何,不​​是我:).

非常感谢提前.

c++ containers iterator vector qt-creator

3
推荐指数
1
解决办法
645
查看次数