How to control actions on tabs (tabwidget) having the same content ?

  • I have tabs added dynamically to a tab widget and having the same content. I want to control actions on every tab for example a click on push button. However, I cannot distinguich between actions on a tab. For example, If I click on button on tab 1, I get that there is a button clicked but I cannot know if it is on tab 1 or on tab 2.

    This is how I add my tabs dynamically :

    def add_new_tab(self,index,text):
       self.new_tab = InterfaceTemplateDialog()

    This is the start of the class InterfaceTemplateDialog:

    lass InterfaceTemplateDialog(QtGui.QDialog, FORM_CLASS):

    def init(self,parent=None):
    super(InterfaceTemplateDialog, self).init(parent)

    self.run_tranus_btn = self.findChild(QtGui.QPushButton,'run_tranus_btn')
    self.spin_box = self.findChild(QtGui.QSpinBox,'spinBox')
    #imploc checkboxes 
    self.checkBox_22 = self.findChild(QtGui.QCheckBox,'checkBox_22') ....etc

    I know that I can get the index of the current tab using ```

    currentIndex = self.tabs.currentIndex()

    but my problem is with the buttons and checkboxes, how to know on which tab the action is performed.

  • Lifetime Qt Champion


    QSignalMapper might be what you are looking for.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.