Using buttons from a QStackedLayout main widget in the current widget



  • Hello,
    I've used the QStackedLayout because of the display convenience that it supports, in which it shows only one widget at a time.
    The way I have set it up is by using a main widget, which holds the QStackedLayout, and adding the needed widgets accordingly.
    Then, I have set up two QPushButton in the main widget and tested them by using them to navigate.
    The question is,
    Is there a way to use said buttons in the added widgets? I intend to use them, for example, to validate a login and to give the main control to the main widget.
    If that idea is wrong, however, I too would like to know.
    Thanks in advance.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you mean QWizard style ?



  • @SGaist Yes.
    However, I've used buttons on each widget accordingly... Would that be better or worse than using a QWizard style layout?


  • Lifetime Qt Champion

    It really depends on your application. One thing to keep in mind is that these buttons should not know what's in e.g. your login widget. They should be enabled when appropriate. Otherwise you are going to have a pretty hard to maintain widget there if you add more "pages".