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. QStackedWidget and QT Creator
Forum Updated to NodeBB v4.3 + New Features

QStackedWidget and QT Creator

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 456 Views
  • 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.
  • MichRX7M Offline
    MichRX7M Offline
    MichRX7
    wrote on last edited by
    #1

    So, trying to play with QStackedWidget and have read the docs for it. If I'm using Creator to modify my app layout I can drag a QStackedWidget onto my layout and it default gives you two stacked widgets. In the docs it states I need to add a QComboBox or a QListWidget. Does this still need to be done? Or is this just to give the user the capability to "switch pages"?

    So, if the user never "chooses" a page, I can change it in the program using setCurrentIndex()?

    And, if so, is it simply done something like this?
    stackedWidget.setCurrentIndex(1);

    JonBJ 1 Reply Last reply
    0
    • MichRX7M MichRX7

      So, trying to play with QStackedWidget and have read the docs for it. If I'm using Creator to modify my app layout I can drag a QStackedWidget onto my layout and it default gives you two stacked widgets. In the docs it states I need to add a QComboBox or a QListWidget. Does this still need to be done? Or is this just to give the user the capability to "switch pages"?

      So, if the user never "chooses" a page, I can change it in the program using setCurrentIndex()?

      And, if so, is it simply done something like this?
      stackedWidget.setCurrentIndex(1);

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #3

      @MichRX7 said in QStackedWidget and QT Creator:

      Does this still need to be done?

      "No" to that one. "Yes" to all your other questions. Which is about what @dheerendra has replied.

      stackedWidget.setCurrentIndex(1) or stackedWidget.setCurrentWidget(one_of_the_widgets_set_via_stackedWidget_addWidget) if you have the widget-page you want shown available to you rather than its index in the QStackedWidget, either one does the job.

      1 Reply Last reply
      1
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #2

        I'm not really sure what is the question here. What is the help you require. Nevertheless QStackWidget name indicates you can add any number & any type of widgets QStackWidget. Show any widget in the stack by setting the current Index.

        You can look at the doc. They have given an example. In the docs they are using the combobox to select the appropriate widget. You can try. This does not mean that you need to always use the combobox to select the widget in stackwidget. Selection of widget can based on some condition.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        1
        • MichRX7M MichRX7

          So, trying to play with QStackedWidget and have read the docs for it. If I'm using Creator to modify my app layout I can drag a QStackedWidget onto my layout and it default gives you two stacked widgets. In the docs it states I need to add a QComboBox or a QListWidget. Does this still need to be done? Or is this just to give the user the capability to "switch pages"?

          So, if the user never "chooses" a page, I can change it in the program using setCurrentIndex()?

          And, if so, is it simply done something like this?
          stackedWidget.setCurrentIndex(1);

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #3

          @MichRX7 said in QStackedWidget and QT Creator:

          Does this still need to be done?

          "No" to that one. "Yes" to all your other questions. Which is about what @dheerendra has replied.

          stackedWidget.setCurrentIndex(1) or stackedWidget.setCurrentWidget(one_of_the_widgets_set_via_stackedWidget_addWidget) if you have the widget-page you want shown available to you rather than its index in the QStackedWidget, either one does the job.

          1 Reply Last reply
          1

          • Login

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