Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. How to control actions on tabs (tabwidget) having the same content ?
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Unsolved Language Bindings
python
2 Posts 2 Posters 975 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 20 Mar 2017, 16:14 last edited by A Former User
    #1

    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()
       self.tabs.addTab(self.new_tab,text)
       self.tabs.setTabText(index,text)
    

    This is the start of the class InterfaceTemplateDialog:

    c```
    lass InterfaceTemplateDialog(QtGui.QDialog, FORM_CLASS):

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

    self.setupUi(self)
    
    
    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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Mar 2017, 22:36 last edited by
      #2

      Hi,

      QSignalMapper might be what you are looking for.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      20 Mar 2017, 16:14

      • Login

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