Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Capture DoubleClick on QTabBar
Qt 6.12 LTS is out! See what's new in the release blog

Capture DoubleClick on QTabBar

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 3 Posters 6.5k Views 3 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.
  • cerrC Offline
    cerrC Offline
    cerr
    wrote on last edited by
    #5

    The class is declared as follows:

    class SessionStack : public QTabWidget
    

    How would I get the tab object using the index?

    mrjjM 1 Reply Last reply
    0
    • cerrC cerr

      The class is declared as follows:

      class SessionStack : public QTabWidget
      

      How would I get the tab object using the index?

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #6

      @cerr
      hi
      Use this function to get the tab
      http://doc.qt.io/qt-4.8/qtabwidget.html#widget

      Can you show me how you define
      tabBarDoubleClicked ?

      cerrC 1 Reply Last reply
      2
      • mrjjM mrjj

        @cerr
        hi
        Use this function to get the tab
        http://doc.qt.io/qt-4.8/qtabwidget.html#widget

        Can you show me how you define
        tabBarDoubleClicked ?

        cerrC Offline
        cerrC Offline
        cerr
        wrote on last edited by
        #7

        @mrjj said in Capture DoubleClick on QTabBar:

        @cerr
        hi
        Use this function to get the tab
        http://doc.qt.io/qt-4.8/qtabwidget.html#widget

        Can you show me how you define
        tabBarDoubleClicked ?

        I hadn't defined it at all but noew added it under

        signals:
            void tabBarDoubleClicked(int index);
        

        which still doesn't seem to be right, I now refer to it like:
        ```
        connect(QTabWidget::widget(tabIndex), SIGNAL(&QTabBar::tabBarDoubleClicked(sessionId)),
        this, SLOT(SessionStack::editTabLabel(sessionId)));

        and get this in the shell:
        

        No such signal Splitter::&QTabBar::tabBarDoubleClicked(sessionId)

        How do I make it link to the correct function/signal? :o
        cerrC 1 Reply Last reply
        0
        • cerrC cerr

          @mrjj said in Capture DoubleClick on QTabBar:

          @cerr
          hi
          Use this function to get the tab
          http://doc.qt.io/qt-4.8/qtabwidget.html#widget

          Can you show me how you define
          tabBarDoubleClicked ?

          I hadn't defined it at all but noew added it under

          signals:
              void tabBarDoubleClicked(int index);
          

          which still doesn't seem to be right, I now refer to it like:
          ```
          connect(QTabWidget::widget(tabIndex), SIGNAL(&QTabBar::tabBarDoubleClicked(sessionId)),
          this, SLOT(SessionStack::editTabLabel(sessionId)));

          and get this in the shell:
          

          No such signal Splitter::&QTabBar::tabBarDoubleClicked(sessionId)

          How do I make it link to the correct function/signal? :o
          cerrC Offline
          cerrC Offline
          cerr
          wrote on last edited by cerr
          #8

          @mrjj said in Capture DoubleClick on QTabBar:

          @cerr
          hi
          Use this function to get the tab
          http://doc.qt.io/qt-4.8/qtabwidget.html#widget

          Can you show me how you define
          tabBarDoubleClicked ?

          I hadn't defined it at all but noew added it under

          signals:
              void tabBarDoubleClicked(int index);
          

          which still doesn't seem to be right, I now refer to it like:

          connect(QTabWidget::widget(tabIndex), SIGNAL(&QTabBar::tabBarDoubleClicked(sessionId)),
            this, SLOT(SessionStack::editTabLabel(sessionId)));
          

          and get this in the shell:

          No such signal Splitter::&QTabBar::tabBarDoubleClicked(sessionId)
          

          How do I get rid of Splitter:: and make it link to the correct function/signal? :o

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #9

            Hi
            First of all the signal:
            signals:
            void tabBarDoubleClicked(int index);

            In which class did you put it?
            You seems to say its the Tab. Is this correct? The signal is defined in Tab class ?

            Also, the syntax seems off. You are mixing syntaxes again.

            connect(QTabWidget::widget(tabIndex), SIGNAL(&QTabBar::tabBarDoubleClicked(sessionId)),
            this, SLOT(SessionStack::editTabLabel(sessionId)));

            try
            with
            QWidget *TheTab= ui->THEQTabWidget->widget(tabIndex);
            qDebug() << " con :" connect( TheTab , SIGNAL(tabBarDoubleClicked(sessionId) ), this, SLOT(editTabLabel(sessionId) );

            it should say "con : true "

            cerrC 1 Reply Last reply
            0
            • mrjjM mrjj

              Hi
              First of all the signal:
              signals:
              void tabBarDoubleClicked(int index);

              In which class did you put it?
              You seems to say its the Tab. Is this correct? The signal is defined in Tab class ?

              Also, the syntax seems off. You are mixing syntaxes again.

              connect(QTabWidget::widget(tabIndex), SIGNAL(&QTabBar::tabBarDoubleClicked(sessionId)),
              this, SLOT(SessionStack::editTabLabel(sessionId)));

              try
              with
              QWidget *TheTab= ui->THEQTabWidget->widget(tabIndex);
              qDebug() << " con :" connect( TheTab , SIGNAL(tabBarDoubleClicked(sessionId) ), this, SLOT(editTabLabel(sessionId) );

              it should say "con : true "

              cerrC Offline
              cerrC Offline
              cerr
              wrote on last edited by
              #10

              @mrjj
              I now have:

              QWidget *tabWidget = QTabWidget::widget(tabIndex);
                  connect(tabWidget, SIGNAL(tabBarDoubleClicked(sessionId)),this, SLOT(SessionStack::editTabLabel(sessionId)));
              

              where

              signals:	
               void tabBarDoubleClicked(int index);
              

              is declared in

              class SessionStack : public QTabWidget
              

              but I get this on the shell:

              QObject::connect: No such signal Splitter::tabBarDoubleClicked(sessionId)
              

              I don't exacltly understand where it gets the reference to Splitter:: from. There is a class that looks like:

              class Session;
              
              class Splitter: public QSplitter
              {
                  Q_OBJECT
              
                  public:
                      explicit Splitter(Qt::Orientation orientation, Session* session, QWidget* parent);
                      ~Splitter();
                      Session* session();
              
                      void recursiveCleanup();
                  private:
                      Session *m_session;
              };
              

              but QSplitter has no DoubleClicked signal.

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

                Hi
                Clean the build folder and run qmake again

                seems it remembers the bad syntax where you used
                &Splitter::tabBarDoubleClicked(sessionId)

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  Also something else:

                  you say:
                  signals:
                  void tabBarDoubleClicked(int index);
                  is declared in class SessionStack : public QTabWidget

                  but when you connect to say its in the tabWidget

                  QWidget *tabWidget = QTabWidget::widget(tabIndex);
                  connect(tabWidget, SIGNAL(tabBarDoubleClicked(sessionId)),this, SLOT(SessionStack::editTabLabel(sessionId)));

                  here u say that tabWidget has the signal. Which seems NOT correct?

                  and please stop using SessionStack:: with SLOT macro.
                  Might still work, but NOT correct.

                  • SLOT(editTabLabel(sessionId)));

                  cerrC 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    Also something else:

                    you say:
                    signals:
                    void tabBarDoubleClicked(int index);
                    is declared in class SessionStack : public QTabWidget

                    but when you connect to say its in the tabWidget

                    QWidget *tabWidget = QTabWidget::widget(tabIndex);
                    connect(tabWidget, SIGNAL(tabBarDoubleClicked(sessionId)),this, SLOT(SessionStack::editTabLabel(sessionId)));

                    here u say that tabWidget has the signal. Which seems NOT correct?

                    and please stop using SessionStack:: with SLOT macro.
                    Might still work, but NOT correct.

                    • SLOT(editTabLabel(sessionId)));

                    cerrC Offline
                    cerrC Offline
                    cerr
                    wrote on last edited by
                    #13

                    @mrjj

                    I deleted all files within build/, re-ran cmake and recompiled but still get:
                    QObject::connect: No such signal Splitter::tabBarDoubleClicked(sessionId)

                    I have now removed the declaration for tabBarDoubleClicked from class SessionStack - do I need it there? As it should come directly from QTabWidget, should it not?

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

                      Hi,

                      Because Splitter::tabBarDoubleClicked(sessionId) is wrong. You don't pass a variable to the connect statement, you pass the parameter type.

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

                      mrjjM 1 Reply Last reply
                      2
                      • SGaistS SGaist

                        Hi,

                        Because Splitter::tabBarDoubleClicked(sessionId) is wrong. You don't pass a variable to the connect statement, you pass the parameter type.

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by mrjj
                        #15

                        @SGaist
                        Good catch :)

                        it should be
                        connect(this, SIGNAL(tabBarDoubleClicked(int)),this, SLOT(editTabLabel(int)));

                        • I have now removed the declaration for tabBarDoubleClicked from class SessionStack - do I need it there? As it should come directly from QTabWidget, should it not?

                        I went and looked at doc for TabBar.
                        http://doc.qt.io/qt-5/qtabbar.html#tabBarDoubleClicked
                        It is indeed the bar that sends the db click.
                        i thought it was a custom signal. sorry about that.
                        So it is pretty simple
                        (inside SessionStack )
                        qDebug() << "con:" << connect(this, SIGNAL(tabBarDoubleClicked(int)),this, SLOT(editTabLabel(int)));

                        that should do it. Check it says true.

                        cerrC 1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @SGaist
                          Good catch :)

                          it should be
                          connect(this, SIGNAL(tabBarDoubleClicked(int)),this, SLOT(editTabLabel(int)));

                          • I have now removed the declaration for tabBarDoubleClicked from class SessionStack - do I need it there? As it should come directly from QTabWidget, should it not?

                          I went and looked at doc for TabBar.
                          http://doc.qt.io/qt-5/qtabbar.html#tabBarDoubleClicked
                          It is indeed the bar that sends the db click.
                          i thought it was a custom signal. sorry about that.
                          So it is pretty simple
                          (inside SessionStack )
                          qDebug() << "con:" << connect(this, SIGNAL(tabBarDoubleClicked(int)),this, SLOT(editTabLabel(int)));

                          that should do it. Check it says true.

                          cerrC Offline
                          cerrC Offline
                          cerr
                          wrote on last edited by
                          #16

                          @mrjj
                          Oh yeah! Wow, cool!
                          Thank you for helping the newbie!!! Much appreciated!

                          1 Reply Last reply
                          1

                          • Login

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