Signal related functions in QtScript (as of Qt 4.5.2) do not fire
I have introduced Qt (4.5.2) to my application by adding my own compatible QtScript assembly and have managed to access all the signals I need. However, when connecting to them (via QtScript), my functions are never called.
I came up with several theories as to why this is the case, and I tested everything I could think of, but I hit the wall a little. Notice I have never had any communication exceptions. Here are my current theories:
- The signals I am connecting to are already connected to other slots and blocking something on it (but as far as I know, all Qt signals are fed to all slots with no extra work and cannot be limited in this way)
- Signals reject my connection or disconnect me after connecting (but I don't see a way to do this)
- My connection comes from a different thread and for some reason it doesn't allow me to connect correctly
Are any of these theories plausible? If not, what am I missing?
a source to share
After digging a lot around the internals and asking a lot of questions (here and in #qt on Freenode viz), I managed to get it to work. The problem was that my injected code was working in a native thread without an emergency pump. Executing QEventLoop and calling processEvents () at regular intervals solved this.
a source to share
This question is really old and already answered, but for those who come here looking for help, and for those who are not a good solution above, you might consider setting the Qt :: ConnectionType in the connect statement in Qt :: Direct connection:
QObject::connect(scrollBar, SIGNAL(valueChanged(int)),
label, SLOT(setNum(int)),
Qt::DirectConnection);
Which should solve the same problem in a different way.
a source to share