Search code examples
pythonpyqtsizeqtabwidgetqsizepolicy

QTabWidget.setFixedWidth() for some tab but not all


My QTabWidget has 4 tabs, the first is fullscreen all other use a fixed Width.

I use a signal to know which tab is used:

self.tab_widget.currentChanged.connect(function)
def function:
    if self.tabWidget.currentIndex():
        self.tab_widget.setFixedWidth(300)
    else:
        # self.tab_widget.setNotFixedSize()
        # I don't know what to write here
        # I only want my Widget use maximum place

When I launch my app I see first tab which is OK (almost fullscreen), if I click on second, widget apply new size and if I come back to first tab, QTabWidget keep wrong size.


Solution

  • By using setMaximumWidth() > window_size, my first tab retreive natural behaviour (it changes size with window resize)