Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Switching between stackedwidgets using ComboBox item click or selection
Qt 6.11 is out! See what's new in the release blog

Switching between stackedwidgets using ComboBox item click or selection

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 929 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.
  • L Offline
    L Offline
    LT-K101
    wrote on last edited by
    #1

    Hi, I want to use ComboBox to switch between stackedwidgets. Example is when the user select or click an item in the comboBox the user should be directed to a specific stackedwidget page. Below is what I have tried but it does not work, please any assistance would be appreciated.

     self.ui.comboBox_73.currentIndexChanged.connect(self.report_page)
    
     def report_page(self):
         self.ui.stackedWidget.setCurrentWidget(self.ui.Second_Page)
    
    jsulmJ 1 Reply Last reply
    0
    • L LT-K101

      Hi, I want to use ComboBox to switch between stackedwidgets. Example is when the user select or click an item in the comboBox the user should be directed to a specific stackedwidget page. Below is what I have tried but it does not work, please any assistance would be appreciated.

       self.ui.comboBox_73.currentIndexChanged.connect(self.report_page)
      
       def report_page(self):
           self.ui.stackedWidget.setCurrentWidget(self.ui.Second_Page)
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @LT-K101 https://doc.qt.io/qt-5/qcombobox.html#currentIndexChanged has a parameter which you can use to activate specific widget (https://doc.qt.io/qt-5/qstackedwidget.html#currentIndex-prop).
      Hint: you can connect the above signal to the above slot.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply
      2
      • jsulmJ jsulm

        @LT-K101 https://doc.qt.io/qt-5/qcombobox.html#currentIndexChanged has a parameter which you can use to activate specific widget (https://doc.qt.io/qt-5/qstackedwidget.html#currentIndex-prop).
        Hint: you can connect the above signal to the above slot.

        L Offline
        L Offline
        LT-K101
        wrote on last edited by
        #3

        @jsulm Thanks I used .activated() and it worked

        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