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. Capture DoubleClick on QTabBar
Forum Updated to NodeBB v4.3 + New Features

Capture DoubleClick on QTabBar

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 3 Posters 5.4k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by mrjj
    #2

    Hi
    Your connect look odd to me. like old and new syntax.

    connect(this, SIGNAL(&QTabBar::tabBarDoubleClicked(session_id)),
    this, SLOT(SessionStack::editTabLabel(session_id)));
    when you use & and :: do not use SIGNAL and SLOT macros.

    also the use of "this" seems not right.
    the syntax is
    connect( pointer to object 1, the signal, pointer to object 2, the slot in obj 2 )
    so you are saying

    connect(SessionStack, SIGNAL(&QTabBar::tabBarDoubleClicked(session_id)),
    SessionStack, SLOT(SessionStack::editTabLabel(session_id)));

    Is the signal not from TabBar? You say its from SessionStack

    also connect returns true or false and it's worth checking out.

    Maybe I read your code wrong but tabBarDoubleClicked seems like your signal? so i assume that your subclassed
    TabBar will emit it?

    1 Reply Last reply
    4
    • cerrC Offline
      cerrC Offline
      cerr
      wrote on last edited by
      #3

      Hi mrjj,

      Thank you for your reply. I can follow through with what you say but have troubles to understand, how I get the handle from my tab added with addTab() to use in connect? I understand that this is the element that will emit the tabBarDoubleClicked signal. So how do I refer to it with connect()?

      Thanks,
      Ron

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

        http://doc.qt.io/qt-4.8/qtabbar.html#addTab
        it returns the index so you can use that to get tab object.

        But Its still not clear to me where signal tabBarDoubleClicked comes from?
        Did you subclass QTabBar and emit this signal on MousePress?

        is SessionStack a QTabBar ?

        1 Reply Last reply
        1
        • 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 Extensions
                                • Unsolved