connect() doesn't seem to "connect"

  • Hi,

    I've asked about this very same issue here before and I was helped. Since then, I have gone away and have now come back only to realize that I cannot seem to get it work correctly anymore... :( What I want, is to capture a double click onto a tab bar and execute a selected method upon that. I think the only thing that's changed was the header file... it looks like:

    #include "session.h"
    #include <QHash>
    #include <QTabWidget>
    class Session;
    class SessionStack : public QTabWidget
        Q_CLASSINFO("D-Bus Interface", "org.kde.kterminal")
            explicit SessionStack(QWidget* parent, QWidget* window);
        public slots:
    	void tabBarDoubleClicked(int index);
        private slots:
    	void editTabLabel(int tabIndex);

    and then in the respective .cpp I have:

    qDebug() << "con:" << connect(this, SIGNAL(tabBarDoubleClicked(int)),this, SLOT(editTabLabel(int)));


    void SessionStack::editTabLabel(int tabIndex)
        bool ok;
        qDebug() << "editTabLabel!";
        if (tabIndex < 0)
        QString text = QInputDialog::getText(this,tr("QInputDialog::getText()"),
    					this->tabText(tabIndex), QLineEdit::Normal,
        if(ok && !text.isEmpty()) {

    but my editTabLabel never gets called even though the call to connect() returns true. What do I have wrong here?

    Thank you!

  • Lifetime Qt Champion


    Why do you declare the void tabBarDoubleClicked(int index) signal in your class? QTabWidget already has one:
    Remove the signal from your class and try again.

  • Bang, that was it! Thank you! :)

Log in to reply