Retrieve value from a signal with the new Qt5 connect syntax
-
Hi everybody,
I'm writing a simple code editor using Qt5 and its new signals & slots syntax. However I got stucked with a trivial problem.
Considering the following class:
@
class CodeEditorTabWidget : public QTabWidget
{
Q_OBJECTpublic: explicit CodeEditor(QWidget* parent = nullptr); signals: void currentChanged(const QString& fileName); private: // Some stuff
};
@The currentChanged signal is emited when the file bein edited has changed. This widget is embedded in a subclass of QMainWindow called MainWindow.
In this class I'd like to do something like:
@
QObject::connect(_codeEditorTabWidget, &CodeEditorTabWidget::currentChanged, [this] () {
setWindowTitle("My editor - " + here the QString emited by currentChanged signal);
});@So my window will have as title: "My editor - /home/kevina/myClass.hpp". And it will change automatically when the user open a new file or switch to another tab.
Is there any way to do so ?
Thanks in advance for any help ;)