Qt World Summit: Register Today!

How to switch forms?

  • i'm new to QT development.
    i'm trying to write a multi-form application that will run on linux/android system.

    so, i read through the documentation, and am able to get a 'hello world' app running on my android box.
    then, put a few buttons/labels/displays on the main form. figure out how to hook up event handlers with the buttons.
    now, i make a second form.
    i want to be able to push the button and bring up the second form. (and more forms as my app progresses).
    can anyone tell me how to do this?


  • Qt on android? What kind of witchcraft is that?

  • it's called neccessitas, and it works great.

  • okay, so i did this in my event handler:

    Screen1 *screen1 = new Screen1();

    Screen1 is of course my other form. this works, except that the new form pops up like a dialog, leaving the original screen running. that's closer, but not quite what i want to do. what i want to do is replace the original ui, along with all it's controls & code.

  • You want hide parent form after showing Screen1, and after close Screen1 back the parent form?
    Did I understand you? If yes, maybe setVisible(bool); can be helpful.

  • Take a look at QStackedWidget!

  • hiding the main window probably isn't quite what i wanted to do.

    i want to be able to start the app with a home screen, then click a button and go to another screen. the second(and subsequent) screens will have their own controls, event handlers, etc. i then want to be able to switch to other screens, as well as return to the 'home' screen.

    i'll take a look at QStackedWidget, that sounds like it might be closer to what i wish to do.

    thanks for input, i'll report back what i discover here.

Log in to reply