hi.
i'm using qt 4.2.x on visual studio + winxp and maybe it sound silly, but the following problem irritates me a little bit:
there is a qthread class, which tires to get new images from a device. the device has a "grab timeout". if a timeout occurs, an exception is thrown. if a new image could be grabbed, a signal should be emitted, transfering the new image to the calling (main/parent) thread for processing/displaying or what ever.
i tried like this...
the threads run method:
void getimg_thread::run()
{
while(!quitthread)
{
try
{
grab_image(&img);
emit newimg(img);
msleep(1);
}
catch(AException &ex)
{
}
}
}
void getimg_thread::run()
{
while(!quitthread)
{
try
{
grab_image(&img);
emit newimg(img);
msleep(1);
}
catch(AException &ex)
{
}
}
}
To copy to clipboard, switch view to plain text mode
the defined signal:
signals:
void newimg(imageobject);
signals:
void newimg(imageobject);
To copy to clipboard, switch view to plain text mode
the slot to receive and process the emitted signal:
private slots:
void newimage_received(imageobject nimg);
private slots:
void newimage_received(imageobject nimg);
To copy to clipboard, switch view to plain text mode
and finally the connect part:
connect(grabimg, SIGNAL(newimg(imageobject)), this, SLOT(newimage_received(imageobject)));
connect(grabimg, SIGNAL(newimg(imageobject)), this, SLOT(newimage_received(imageobject)));
To copy to clipboard, switch view to plain text mode
but my headache starts here: the connect does not work somehow, my slot is never called. i tried many things, but without any luck.
it somehow just worked as i emitted an "int". then my slot was called properly. i also tried to emit a signal with a QList<int>, which is also working, e.g.:
...
signals:
void newimg(const QList<int>*);
...
QList<int> *a = new QList<int>;
a->append(1);
emit newimg(a);
...
private slots:
void newimage_received(QList<int> *nimg);
...
connect(grabimg, SIGNAL(newimg(QList<int> *)), this, SLOT(newimage_received(QList<int> *)));
...
...
signals:
void newimg(const QList<int>*);
...
QList<int> *a = new QList<int>;
a->append(1);
emit newimg(a);
...
private slots:
void newimage_received(QList<int> *nimg);
...
connect(grabimg, SIGNAL(newimg(QList<int> *)), this, SLOT(newimage_received(QList<int> *)));
...
To copy to clipboard, switch view to plain text mode
but if i'm using my imageobject class (which is not a qt object), it won't work:
...
signals:
void newimg(QList<imageobject>*);
...
QList<imageobject> *a = new QList<imageobject>;
a->append(img);
emit newimg(a);
...
private slots:
void newimage_received(QList<imageobject> *nimg);
...
connect(grabimg, SIGNAL(newimg(QList<imageobject>*)), this, SLOT(newimage_received(QList<imageObject>*)));
...
...
signals:
void newimg(QList<imageobject>*);
...
QList<imageobject> *a = new QList<imageobject>;
a->append(img);
emit newimg(a);
...
private slots:
void newimage_received(QList<imageobject> *nimg);
...
connect(grabimg, SIGNAL(newimg(QList<imageobject>*)), this, SLOT(newimage_received(QList<imageObject>*)));
...
To copy to clipboard, switch view to plain text mode
i'm confused. why is QList<int> working and QList<imageobject> not? i mean, an emitted signal is able to transfer any object i define or not!? any ideas? help :|
regards,
criss
Bookmarks