简体   繁体   中英

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). So I created my first QTableView with everything it needs and added a second on top, which only shows the header. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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