[Interest] QTabWidget scroll buttons

Matthew Woehlke mwoehlke.floss at gmail.com
Tue Mar 26 16:15:19 CET 2019


On 26/03/2019 09.56, Murphy, Sean wrote:
> Is there a way to get access to the scroll buttons on a QTabWidget to customize them?
> 
> The issue we're having is that we have a UI that uses a tab widget for displaying file contents - one tab per open file. Once a user opens enough files/tabs, the tab scroll buttons pop up (so far so good), but then the user keeps opening more tabs. Eventually they have enough open that it can take quite a while to navigate between open tabs since each click on a scroll button only shifts the visible tabs over by one tab per click. For example, if they have 10 tabs open, and because of screen size, tab elide mode, etc., they can only see 3 tabs at a time, if they are currently looking at the 10th tab, but want to then go view the 1st, they have to click 7 times to get over to the first tab.
> 
> A request has come in to allow the user to right-click on the scroll buttons, which would then open a popup menu of all open tab names which they can select from, and then I could just set the selected tab as the currentIndex(). But I don't see anything on https://doc.qt.io/qt-5/qtabwidget.html that talks about those scroll buttons beyond just the usesScrollButtons property. So I'm not sure how to specifically trigger off from a right click on the scroll arrows themselves...

Honestly... you might want to seriously consider not using QTabWidget.
I'm not saying "don't use a tabbed UI", just don't use QTabWidget
specifically. With that many tabs, I start to wonder if you eventually
get into performance issues with all of the widgets for each tab (I
assume each tab has the same UI?).

Instead, you might want to look at e.g. KDevelop, Konqueror or Falkon
(maybe Qt Creator can be added to that list also?) to see what they do.

-- 
Matthew



More information about the Interest mailing list