Qt Increase QTabWidget's QTabBar size
Asked Answered
W

2

26

I need to make the tabs that I have oriented at the bottom of my QTabWidget larger. We'll be using a touch-screen, so the default sizes are a little too small.

I see no easy way to do this (currently seeing no good way to even do it at all. The only methods pertaining to the QTabBar that I see in QTabWidget are protected, and I don't see a need to inherit from the class other than for this express purpose).

Question:

What I'd like to do is to just set the QTabBar to a certain specific size. Is this possible?

Other than this, the only thing I can think of is to subclass QTabWidget and then I can control the size of the QTabBar by extending or overriding features of this class.

Thanks.

Weikert answered 12/11, 2009 at 21:38 Comment(0)
F
43

If you don't want to subclass stuff, you can use Qt stylesheets to quickly set the height and width of your tabs like so:

// tabWidget is a pointer to a QTabWidget
tabWidget->setStyleSheet("QTabBar::tab { height: 100px; width: 100px; }");
// each tab should now be 100x100px

Note that the stylesheet refers to QTabBar even though we're calling setStyleSheet() on QTabWidget.

Festinate answered 13/11, 2009 at 5:53 Comment(3)
I recommend using stylesheets as well.Capacitor
this works like a charm in linux... but doesn't show any effect on mac. Any idea why?Leicestershire
the pane follows the width of its tab combined. how to avoid thisDisputatious
C
9

If your using Qt Designer you can simply put QTabBar::tab { height: 100px; width: 100px; } in the stylesheet property of the QTabWidget objet directly

Capacitor answered 13/11, 2009 at 6:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.