Unsolved Catching a signal from an other class
-
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. -
Hi! See Signals & Slots.
-
@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 }
myImageButton
is a pointer to your ImageCorrectButton. I assumed them_selectedFile
was a QString and added that as the param type.