简体   繁体   English

为什么我的滚动条不能正确同步?

[英]Why won't my scrollbars synchronise properly?

I've evaluated several ways to create a QTableView with a hierarchic header and decided on faking it (seemed easy at the time). 我评估了几种创建带有分层标题的QTableView的方法,并决定伪造它(当时看起来很容易)。 So I created my first QTableView with everything it needs and added a second on top, which only shows the header. 因此,我创建了第一个QTableView并具有所需的一切,并在顶部添加了第二个,它仅显示标题。 I set it up so it looks nice and all, and then started to synch the scrollbars. 我对其进行了设置,使其看起来不错,然后开始同步滚动条。
The vertical scrollbar was not a problem, since the 'fake header' table won't scroll vertically. 垂直滚动条不是问题,因为“假标题”表不会垂直滚动。
The horizontal scrollbar seemed to be okay too, until I noticed that the tables scroll at different speeds. 水平滚动条似乎也没问题,直到我注意到表格以不同的速度滚动。 So basically my 'fake Header' scrolls faster than my actual table. 因此,基本上我的“假标题”滚动得比我的实际表快。 The illusion of one header is quite literally ripped apart. 一个标题的错觉在字面上被撕裂了。

Now I was thinking, maybe they scroll at a relative pace to their size, so I adjusted the width of both tables to be exactly the same. 现在我在想,也许它们以相对的速度滚动到它们的大小,所以我将两个表的宽度调整为完全相同。 This didn't change anything, though. 但是,这没有任何改变。

So, I'm out of ideas for now. 因此,我暂时没有想法。 Any suggestions? 有什么建议么?

I'm suspecting that your scrollbars don't have the same range. 我怀疑您的滚动条没有相同的范围。 You should connect the rangeChanged(int,int) signal from one of your scrollbars to some function, where you set the range of your other scrollbar to those values. 您应该将来自一个滚动条的rangeChanged(int,int)信号连接到某个函数,在此将另一个滚动条的范围设置为这些值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM