Solved Capture DoubleClick on QTabBar
-
@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#widgetCan 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
-
@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#widgetCan 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
-
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 "
-
@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.
-
Hi
Clean the build folder and run qmake againseems it remembers the bad syntax where you used
&Splitter::tabBarDoubleClicked(sessionId) -
Also something else:
you say:
signals:
void tabBarDoubleClicked(int index);
is declared in class SessionStack : public QTabWidgetbut 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)));
-
-
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?
-
Hi,
Because
Splitter::tabBarDoubleClicked(sessionId)
is wrong. You don't pass a variable to the connect statement, you pass the parameter type. -
@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.
-
@mrjj
Oh yeah! Wow, cool!
Thank you for helping the newbie!!! Much appreciated!