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. Similar reference for different tabs in tabwidget (Strange problem )
QtWS25 Last Chance

Similar reference for different tabs in tabwidget (Strange problem )

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 3 Posters 2.2k 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 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are printing the result of the creation of a new InterfaceTemplateDialog. What's your point in doing that ?

      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
      1
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hello,

        I want to add an attribute in my class InterfaceTemplateDialog which is index so I can after perform actions on every tab by his index. Example :

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

        and run_btn_start() will be implemented in InterfaceTemplateDialog

        Getting the same reference for different tabs make me doubt about a strange problem.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Hello again,

          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.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            That's pretty convoluted.

            You seem to be creating InterfaceTemplateDialog for each tab in your QTabWidget and then in your onChange method you seem to create a new InterfaceTemplateDialog to call a function on it. That doesn't make much sense.

            What exactly do you want to do ? And when ?

            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
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              My tabs have the same content (widget) with same buttons, checkboxes, .. What I want to do exactly is to execute actions (button click ..) on a selectioned tab .

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Then create your widget, then the connections for that widget and finally add it to your QTabWidget.

                However, why do you need a QTabWidget that contains the exact same widget several times ?

                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
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  Hello,

                  Actually, there is a table with serveral columns. Now, we want to transform this table to a tabwidget beacause, may be we can have many columns so the size of the table will be not sufficient.

                  jsulmJ 1 Reply Last reply
                  0
                  • ? A Former User

                    Hello,

                    Actually, there is a table with serveral columns. Now, we want to transform this table to a tabwidget beacause, may be we can have many columns so the size of the table will be not sufficient.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @EJWA If the table is too big how can tab widget help?
                    You should put your table into QScrollArea http://doc.qt.io/qt-5.8/qscrollarea.html

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

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      Hi, this is what my client want. I think tabs are more beautiful in design than tables.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        What kind of table ? Showing what ?

                        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
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #12

                          Table with different scenarios (use cases) : every column has many checkboxes to check to run the program selected

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            Then why don't you put the active logic directly in your InterfaceTemplateDialog ?

                            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

                            • Login

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