1
votes

Just a main widget with a tabs widget in it.

The problem is - when I run it, only part of tabs are shown (as shown on attached picture). So, you need to resize, or scroll tabs to get for the last.

enter image description here

How can I set it so that window shows all tabs from the start?

import sys
from PyQt4.QtGui import *

class MainWindow(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        # making tabs
        tabs = QTabWidget()
        tabs.addTab(QWidget(), '111111')
        tabs.addTab(QWidget(), '222222')
        tabs.addTab(QWidget(), '333333')
        tabs.addTab(QWidget(), '444444')

        # inserting in vbox
        vbox = QVBoxLayout(self)
        vbox.addWidget(tabs)

app = QApplication(sys.argv)
myapp = MainWindow()
myapp.show()
sys.exit(app.exec_())

How can I get it resized for all tabs?
And where the problem is - is it parent widget, or tabs, or vbox?

1

1 Answers

3
votes

You can use QTabWidget.setUsesScrollButtons(bool)

import sys
from PyQt4.QtGui import *

class MainWindow(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        # making tabs
        tabs = QTabWidget()
        tabs.setUsesScrollButtons(False) #here is

        tabs.addTab(QWidget(), '111111')
        tabs.addTab(QWidget(), '222222')
        tabs.addTab(QWidget(), '333333')
        tabs.addTab(QWidget(), '444444')
        # inserting in vbox
        vbox = QVBoxLayout(self)
        vbox.addWidget(tabs)

app = QApplication(sys.argv)
myapp = MainWindow()
myapp.show()
sys.exit(app.exec_())

http://doc.qt.nokia.com/4.7/qtabwidget.html#usesScrollButtons-prop