tags:

views:

299

answers:

3
A: 

I think you need to use a blocking direct connection, although be aware that the slot will be executed in the MainWindow's thread:

connect(this, SIGNAL(PenOn(QPoint)), &d, SLOT(on_PenOn(QPoint)), Qt::BlockingQueuedConnection);

See http://qt.nokia.com/doc/4.5/qt.html#ConnectionType-enum for more info.

The problem with using the default Qt::ConnectionType for the connect method is that since the objects are in different threads, the slot will not be called until the dialog thread gets back to it's main loop, which will only happen after the d.exec() loop is finished.

Ben
Unfortunately, this does not work too. I'm a bit confused by exec() method. The parent window still receives and processes signals from working thread when exec is triggered (that's ok) so I don't understand why the dialog windows does not receive main window signals. After some debugging in /*!\internal */void QMetaObject::activate if ((sender->d_func()->connectedSignals[n] returns true and method returns.
bartek
Making a dialog non modal does not solve the problem either.
bartek
There should be no problem with different threads here, as both classes are UI classes, and must be in the same (first) thread. The type of connection for that signal should default to direct, which would call it immediately.
Caleb Huitt - cjhuitt
A: 

Still does not know what's going on. I made use of QEvent and solved problem this way.

bartek
A: 

My first guess on the problem is that you don't have the Q_OBJECT macro in one of your classes, or possibly both. If you do but added it after you generated your makefile, you may need to re-run qmake to regenerate the makefile (or whatever you use on your platform) to let it know that the moc needs to be run on those classes. If the moc isn't run over your classes, it doesn't generate the code required to add the signal and slot information to the class, and the connections will fail.

Caleb Huitt - cjhuitt
Hi, unfortunately both classes have Q_OBJECT macro, in fact, both headers were generated by Qt Designer, I tried remaking the whole project too. Still no success. Fortunately sending event works as a charm.
bartek