Catching a signal from an other class
-
Hi! See Signals & Slots.
-
Hi,
I'm emitting a signal in ImageCorrectButton.cpp:emit selectedFileChanged(m_selectedFile);How can I catch this signal in an other class (mydelegate.cpp)?
Please show me an example if possible.
Thank you.@gabor53 You definitely need to read the docs that @Wieland linked, but to give you the quick version:
class MyDelegate : public QObject { Q_OBJECT // ... private slots: void fileChanged(QString); // ... } void MyDelegate::someFunction() { connect(myImageButton, SIGNAL(selectedFileChanged(QString)), this, SLOT(fileChanged(QString))); } void MyDelegate::fileChanged(QString) { // this gets called on signal }myImageButtonis a pointer to your ImageCorrectButton. I assumed them_selectedFilewas a QString and added that as the param type.