[Qt-interest] Runtime Error :- connect: No such slot ...
Sean Harmer
sean.harmer at maps-technology.com
Fri Feb 19 12:38:24 CET 2010
On Friday 19 February 2010 11:27:01 Andreas Pakulat wrote:
> On 19.02.10 11:13:59, Wm. G. Urquhart wrote:
> > Well needless to say I didn't find anything wrong when creating this
> > sample (is it that obvious?), so here it is.
> >
> > This version uses a const QString & instead of an int but at runtime the
> > outcome is the same:
> >
> > Object::connect: No such slot QPushButton::setText(const QString &) in
> > .\sigtest.cpp:9
> > Object::connect: (receiver name: 'pushButton')
>
> If you look at the API docs you'll notice that setText is not a slot,
> its a normal member function. Hence QObject::connect is correct.
Andreas is correct. To make it into a slot you will need to derive your own
class from QPushButton and do it there.
The more serious problem though is that you are not using a queued connection
between a signal emitted in a worker thread and (what would be) a slot in the
GUI thread. In this case you should specify Qt::QueuedConnection explicitly as
the last parameter of your connect statement.
Normally connect is smart enough to figure this out, but in your case the
QThread object has affinity with the GUI thread even though you emit the signal
in the context of the worker thread. So you need to be explicit here.
Cheers,
Sean
More information about the Qt-interest-old
mailing list