QTabWidget, how to align tab?
-
Dear all,
I have a newbie and need support. I develop a desktop application using PyQt5. In the app, there is a screen that contains a QTabWiget and some tabs were included in it. I want to order the tab position on both the left and right sides (as in the demo image). I have some questions:
1 - Can I do like as the demo image?
2 - If yes, what function should I use?
3 - If not, is there any solution to do it?
Thank you very much (bow)
-
@ducdx
Not a full solution, but FYI.QTabBar is the widget for the actual tabs (i.e. the rectangles with the numbers on them).
I don't think you can have "some tabs at the left, some at the right, and a gap in between".
That class has an
virtual protected QSize QTabBar::tabSizeHint(int index) const
. Which returns the size of the tab forindex
, i.e. per tab. If you subclassQTabBar
you could use that to tell it tab #4 or #5 is "very wide". Mind, it would draw the tab all the way vetween #4 & #5, but maybe you could affect that. It's a start.A totally different way is to "insert an invisible tab (which is wide) between tabs #4 & #5". See e.g. https://stackoverflow.com/a/14677571/489865. Be careful that your "real" tabs will now not be sequential.