2

I didn´t find a example to put the different tabs of QTabWidget in different files. Just a Methode or as a new (child-)class. I´m a beginner in Python with QT and thought I can get a better overview if I put the different tabs in different classes.

I have the following class in a MainWindow:

class pages(QTabWidget):
    def __init__(self, parent = None):
        super(pages, self).__init__(parent)
        #Variables
        self.inputFile = 0
        self.tab1 = QWidget()
        self.tab2 = page2()


        self.addTab(self.tab1,"Tab 1")
        self.addTab(self.tab2,"Tab 2")

        self.tab1UI()
        #self.tab2UI()

        self.setWindowTitle("tab demo")

(The commented tab2 I tried to get into another class which is called page2(). tab1UI ist still a method within the class pages.)

Furthermore, is it possible to Access variables in a tab in a child class to a parent one by super or something?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
dominikTO
  • 25
  • 4
  • I don't understand. There should be only *one* tab widget, then you add your own widgets as tabs. Make new subclasses of QWidget for each different tab you need, then create an instance for each one and use `addTab` to add it. – musicamante Apr 01 '20 at 18:20
  • That post may be interesting and have a look [https://stackoverflow.com/questions/57749660/loading-different-qwidgets-dependant-on-highlighting-row-of-qtablewidget] (loading-different-qwidgets-dependant-on-highlighting-row-of-qtablewidget) – Pavel.D Apr 01 '20 at 19:19

0 Answers0