Loading different classes in same window



  • Hello ,
    I was wondering if there is a way to load different ui in the same MainWindow.
    Take for eg . chrome browser . The MainWindow i.e the toolbar , menubar ,etc does not change. Only the data inside the mainwindow changes.
    Is there a way to include all classes in one mainwindow and then show different classes on different events in the mainwindow.
    The way i know is to add another window and then show that window from the mainwindow.
    I hope you got what i'm trying to say.
    Thanks.


  • Lifetime Qt Champion

    Hi,

    Do you mean something like the QStackedLayout or its friend the QStackedWidget?



  • @SGaist

    I don't think stack widgets will help.
    I need an entire ui . Not just a widget.
    eg .
    When i click login button in a login form.
    The form should load into another form.
    The only thing is it should not open a new window.
    It should load in the same mainwindow.
    Thank you.


  • Lifetime Qt Champion

    So basically you have LoginWidget -> successful login -> PresentationWidget and all in a QMainWindow, right ?

    If so you can put both LoginWidget and PresentationWidget in a QStackedWidget and use that QStackedWidget as central widget of your QMainWindow.



  • @SGaist
    Yes exactly ,
    The question is how do i put the login widget and presentation widget in QStackedwidget
    Where do i declare QStackedwidget and how to include the 2 mainwindows.
    Sorry for this but i searched and i'm only getting answers for a single stacked widget.
    Thank you.


  • Lifetime Qt Champion

    Because there's no need for two QStackedwidget. Use one in which you put both your other widgets. Also it looks like you are trying to base all your widgets on QMainWindow. Although possible, that usually doesn't make sense.



  • @SGaist
    I just want 1 window with the forms changing for the login and presentation windows.
    And then ill use dialog windows after the presentation window.
    Anyways thank you. Ill try QStackedWidget.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.