class derivated from QImage as parameter of signal
-
Hi,
How to send an Image * (derivated from QImage) as parameter of a signal ?I have put:
Q_DECLARE_METATYPE(Image)
Q_DECLARE_OPAQUE_POINTER(Image *) -
Hi
Sending a pointer requires nothing extra as its a value and can be copied and queued by default.
So you can just do it.signals: void mysignal(Image *); public slots: void myslot(Image *);
connect(this, &MainWindow::mysignal, this, &MainWindow::myslot ); auto test = new Image; emit mysignal(test);
and it will work.
-
@mrjj thank you but is it possible to send as parameter of a signal a QString & ?
because my signal is mysignal(Image*,QString &) and I don't receive the signal
it is emitted from the end of the function run from a class derivated from QThread to the mainwindow. -
Hi
QString already works in any combination so that should not be it.
mysignal(Image*,QString &) should also just work. ( slot has to match of cause )So i think it something else :)
-
Hi,
Why are you sending a pointer to a QString ?
-
@SGaist I send the pointer on the resulting image and the pointer on the filename of the original image because in my slot I compute the filename of the resulting image and I display this image.But with the pointer on QString as parameter in the signal it works
-
Then you should rather use a const reference. But since you embed that file path in your class, why not use that ?