QT:在 QTabBar 块中定位选项卡
有一个具有正在扩展的垂直尺寸策略的 QTabBar 元素。我想让选项卡与 QTabBar 元素框的底部对齐,但它们总是从顶部出现。
我尝试过使用 vertical-align:bottom
、alignment:bottom;
、bottom:0;
的不同组合来设计 QTabBar 和 QTabBar::tab 的样式但运气为零。似乎唯一有效的对齐方式是水平对齐。
当前结果:
选项卡与内容所在位置分开。在建议我不要使用扩展的垂直政策之前。我必须这样做,我有我的理由。
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 before suggesting me to not use an expanding vertical policy. I have to do it like this, I have my reasons.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
小部件对齐可以在包含布局中设置,并且您必须使用非零拉伸值:选项
卡将正确对齐,其上方有空白空间,但该空间不会成为 QTabBar 的一部分(扩张政策将被忽略)。
如果您需要在
QTabBar
上方的空间中放置一些内容,您可以将其插入到另一个中间QWidget
的底部,并将该小部件插入布局而不是>QTabBar
。The widget alignment can be set in the containing layout, and you have to use a non-zero stretch value:
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 intermediaryQWidget
and insert that widget into the layout instead of theQTabBar
.