pythonqttabspyqttabwidget

Similar reference for different tabs in tab widget ? Strange


I am creating tabs dynamically in a tabwidget using this method :

 def add_new_tab(self,index,text):

    self.new_tab = InterfaceTemplateDialog()
    self.tabs.addTab(self.new_tab,text)
    self.tabs.setTabText(index,text)

Trying to print the reference of selected tab using this method :

def onChange(self):

    currentIndex = self.tabs.currentIndex()
    print InterfaceTemplateDialog()

I get the same reference for every selected tab except for the first selected:

<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F842F0>
<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F8EE18>
<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F8EE18>
<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F8EE18>
<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F8EE18>

If references are similar, I cannot control actions on tabs.

So what is this strange problem ?

Thank you in advance for your help.


Solution

  • I think the correct way to get the correct reference is to use :

    currentTabWidget = self.tabs.currentWidget()

    with self.tabs = self.findChild(QtGui.QTabWidget, 'tabWidget')

    I tested, it works well. Thanks.