Warm tip: This article is reproduced from stackoverflow.com, please click
c++ QT

Qt: how to force QTabBar to fill whole layout?

发布于 2020-11-29 11:57:02

I have a custom QTabWidget which holds a custom QTabBar. I want to expand the area of the QTabBar (the red area) all the way to the right side of the window without enlarging the tabs themselves.

enter image description here

I have already tried settings the QTabBar's horizontal size policy to QSizePolicy::Ignored or QSizePolicy::Expanding, but these do nothing. It seems like the QTabBar is being constrained by the QTabWidget, but I don't know why or how to work around this.

edit:

enter image description here

I want the tab bar to take up the green area in addition to the red area. I am trying to implement drag&drop tabs - I need the QTabBar to take up all of the horizontal space so tabs can be dragged at the end of it.

Currently, my custom TabBar is just a standard QTabBar with the drag&drop events caught.

Questioner
poppy
Viewed
1
poppy 2020-07-24 05:49

setDocumentMode(true)

is what I was looking for.