QTreeView水平滚动条问题 [英] QTreeView Horizontal Scrollbar problems

查看:161
本文介绍了QTreeView水平滚动条问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对QTreeView水平滚动条有问题,它没有出现.我已经将水平滚动条策略设置为ScrollBarAsNeeded,但是如果需要的话它不会出现.尝试将展开和折叠的信号连接到插槽:

I've a problem with QTreeView horizontal scrollbar, it doesn't appear. I've set horizontal scrollbar policy to ScrollBarAsNeeded, but it doesn't appear if needed. Have tried to connect expanded and collapsed signals to a slot:

connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex)));
connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex)));

该插槽包含一行代码:

update_scroll_area(const QModelIndex& i)
{
    resizeColumnToContents(i.column());
}

这使滚动条起作用,但仅当我正在扩展/折叠树状视图项时才起作用.

This makes scrollbar working, but only when I'm expanding/collapsing the tree view items.

从启动应用程序到结束,我需要一直"使用水平滚动条.如何组织?

I need to have working horizontal scrollbar "every time", from starting the application till its end. How can it be organized?

谢谢.

推荐答案

This FAQ entry may help.

简而言之:

  • 设置水平标题以将其大小调整为列的内容(即使标题被隐藏,这也适用)
  • 禁用"stretchLastHeaderSection"属性,以防止水平标题自动调整为视口的宽度(似乎覆盖了上面的设置,以调整为列的大小)

这篇关于QTreeView水平滚动条问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆