Nudlwoodz7756 | 2020-10-06 13:15:53 UTC | #1
Hi together,
i´m new to Python and am stuck with a problem where I can´t find a solution. Perhaps (or nearly sure) the problem exists just between the Headset ^^
I´m trying to (actually still as an exercise) create a Layout in PyQt5 and trying to implement different Layouts into 1 QHBoxLayout. Everything works fine, but I am not able to integrate a QTabWidget beside other Layouts. When I´m trying to do so, it´s getting the only Layout on the surface as if no other one´s would have been implemented.
Here´s my code :
def createLayout(self):
    ############ LayoutTests #############################
    HLayout1 = QtWidgets.QHBoxLayout()
    VLayout1 = QtWidgets.QVBoxLayout()
    VLayout2 = QtWidgets.QVBoxLayout()
    VLayout3 = QtWidgets.QVBoxLayout()
    VLayout4 = QtWidgets.QVBoxLayout()
    VLayout5 = QtWidgets.QVBoxLayout()
    HLayout2 = QtWidgets.QHBoxLayout()
    GridLayout = QtWidgets.QGridLayout()
    StackedLayout = QtWidgets.QStackedLayout()
    TabWidget = QtWidgets.QTabWidget()
    VLayout1.addWidget(Color("black"))
    VLayout1.addWidget(Color("red"))
    VLayout1.addWidget(Color("yellow"))
    VLayout1.setContentsMargins(0,0,20,0)
    VLayout1.setSpacing(20)
    HLayout1.addLayout(VLayout1)
    HLayout1.addWidget(Color("green"))
    VLayout2.addWidget(Color("blue"))
    VLayout2.addWidget(Color("purple"))
    HLayout1.addLayout(VLayout2)
    GridLayout.addWidget(Color("Grey"), 0, 3)
    GridLayout.addWidget(Color("black"), 1, 0)
    GridLayout.addWidget(Color("DarkGrey"), 1, 1)
    GridLayout.addWidget(Color("orange"), 2, 1)
    HLayout1.addLayout(GridLayout)
    TabWidget.setDocumentMode(False)
    TabWidget.setTabPosition(QtWidgets.QTabWidget.North)
    TabWidget.setMovable(True)
    Tab1 = QtWidgets.QWidget()
    Tab2 = QtWidgets.QWidget()
    TabWidget.addTab(Tab1, "Tab1")
    TabWidget.addTab(Tab2, "Tab2")
    VLayout3.addWidget(TabWidget)
    **# here´s the Problem beginning, whenever I want to integrate the VLayout3 **
   ** # into the HLayout1 it´s getting the one and only **
    ** #HLayout1.addLayout(VLayout3) **
    Widget = QtWidgets.QWidget()
    Widget.setLayout(HLayout1)
    self.setCentralWidget(Widget)
This is the Layout before and after :

When activating again the Line "HLayout1.addLayout(VLayout3) " it´s getting the only one that´s visible.
Purchasing Power Parity
Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]I don´t understand why it´s getting dominant as the only one. Isn´t it possible to have a QTabWidget in a Layout besides other Layouts ?
Nudlwoodz7756 | 2020-11-16 09:35:58 UTC | #2
I´ll answer it for myself ;)
Create GUI Applications with Python & Qt5 by Martin Fitzpatrick — (PyQt5 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!
I managed to get it running.
Obvisously it´s just possible to add a QTabWidget inside a GroupBox. So, GroupBoxes besides GroupBoxes where the QTabWindow is inside is possible. Without the GroupBoxes it´s becoming dominant like a Borg.
Create GUI Applications with Python & Qt6 by Martin Fitzpatrick — (PyQt6 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!