0
votes

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.

2
Could you make a sketch of what it is you want to achieve?André
How is your custom QTabBar implemented?scopchanov
I've updated my original post.poppy

2 Answers

0
votes

There is no straightforward way to do this. There is QTabBar::setExpanding(), but I just tried and it didn't work.

I did see however QTabBar::setMinimumWidth() and you can effectively use this method to achieve your desired behavior. Here's roughly how your code will look like:

class MyTabWidget : public QTabWidget {
    Q_OBJECT
protected:
    void showEvent(QShowEvent *event) {
        tabBar()->setMinimumWidth(size().width() / tabBar()->count());
        QTabWidget::showEvent(event);
    }
}
0
votes

setDocumentMode(true)

is what I was looking for.