Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Recommended way to change the user interface at runtime
Forum Updated to NodeBB v4.3 + New Features

Recommended way to change the user interface at runtime

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rexona for men
    wrote on last edited by
    #1

    Say, I've created several forms with the Qt Designer, one main window and some widgets. One widget is a little welcome screen that should be displayed at start and as a default screen when no document is open. The application shall create Dungeons & Dragons characters. This welcome screen should be swapped with widgets reponsible for creation and editing of characters, depending what the user wants to. While the welcome screen has no own logic, so it is only a form, the other widgets are actual classes. The problem now is how can I switch between this widgets at runtime.

    I tried to use setupUi() on the central widget of the main window, with no success.
    Then I created a new layout for the central widget, deleting the old one of course, but while the new widgets appears, the old welcome screen is still there.
    So I went on to delete the central widget and recreate a new one. This was actually succesful, but now the menu bar of the main window wouldn't react on input.

    So far, I need some advice on how to change my user interface at runtime.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      You could make your central widget a QStackedWidget, and put the "Welcome" screen on the first page, and the "Character Creation" screen on the second page

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rexona for men
        wrote on last edited by
        #3

        Thank you a lot, I knew, there would be such a possibility, I just didn't find it.

        Since I have to put the forms with an actual logic behind it manully into the widget stack, are widgets contructed via new properly deleted?

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          The ownership of the widget is passed on to the QStackedWidget, so it is deleted once the QStackedWidget is deleted.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved