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. How to identify which tab is selected
Forum Updated to NodeBB v4.3 + New Features

How to identify which tab is selected

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.2k 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.
  • M Offline
    M Offline
    martinbach
    wrote on last edited by
    #1

    I have a QMainWindow with a QPushButton and a QTabWidget formed by 4 tabs:
    in each tab there are 5 QRadioButton (for a total of 20)

    When the QMainWindow starts, all the QRadioButton are deselected, but if the user select one QRadioButton from the first tab, then click the third tab and select another QRadioButton when he pushes the QPushButton I don't know which QRadioButton is selected.

    How can I determine the current tab so I can know the QRadioButton associated with ?
    Is it possible when a user switch between the tabs to deselect all the QRadioButton in the current tab ?

    I'm a totally newbie and I'm using pyside.

    Thanks for your help.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clochydd
      wrote on last edited by
      #2

      Hi, you may determine the current tab by using ui->tab->currentIndex().
      The QRadioButtons can be selected with *ui->tab->findChildren<QRadioButton >();

      1 Reply Last reply
      0
      • M Offline
        M Offline
        martinbach
        wrote on last edited by
        #3

        Thanks for your reply. I think now to be able to know which is the current tab when the user press the button:

        @def push_button_clicked(self):
            if self.tabWidget.currentIndex() == 0:
                # check all radioButton from current tab
                print 'user on first tab', self.tabWidget.currentIndex()
            elif self.tabWidget.currentIndex() == 1:
                # check all radioButton from current tab
                print 'user on second tab', self.tabWidget.currentIndex()
            elif self.tabWidget.currentIndex() == 2:
                # check all radioButton from current tab
                print 'user on third tab', self.tabWidget.currentIndex()
            elif self.tabWidget.currentIndex() == 3:
                # check all radioButton from current tab
                print 'user on fourth tab', self.tabWidget.currentIndex()@
        

        Is there a way to deselect the radioButton ?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          clochydd
          wrote on last edited by
          #4

          Yes, you can use

          @
          ui->radioButton.setChecked(false);
          @

          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