QT: Position tabs within QTabBar block
There is a QTabBar element with a vertical size policy which is expanding. I want to make the tabs to be aligned to the bottom of the QTabBar element box, but they are always appearing from the top.
I have tried styling QTabBar and QTabBar::tab with different combinations of vertical-align: bottom
, alignment: bottom;
, bottom:0;
but with zero luck. It seems that the only alignment that actually work is when I align horizontally.
Current results:
The tabs are separated from where the content will go. And bef开发者_JS百科ore suggesting me to not use an expanding vertical policy. I have to do it like this, I have my reasons.
The widget alignment can be set in the containing layout, and you have to use a non-zero stretch value:
vbox->addWidget(tabBar, 1, Qt::AlignBottom);
vbox->addWidget(otherWidget, 1);
The tab will be correctly aligned, with empty space above it, but that space won't be a part of the QTabBar (the expanding policy will be ignored).
If you need to put something in the space above the QTabBar
, you could insert it at the bottom of another intermediary QWidget
and insert that widget into the layout instead of the QTabBar
.
精彩评论