开发者

QT: Position tabs within QTabBar block

开发者 https://www.devze.com 2023-04-06 06:34 出处:网络
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.

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:

QT: Position tabs within QTabBar block

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消