PDA

View Full Version : How to make the application to process signals immediately



venk2ksubbu
25th June 2010, 14:04
Hi All,

I have following classes:

Class topLevel creates objects of classes A and B.

There is a signal named 'Out' in class A and slot named 'Print' in class B. Now the signal 'Out' from class A is connected to slot 'Print' of class B in the object of topLevel class.

class C inherits class A. In class C I am creating a process using QProcess. Also I am creating a thread using QThread which reads standard output from the above mentioned process and emits a signal, which internally emits 'Out' signal of class A. But I observed that the signal is not processed immediately. It takes lot of time to print the output, as I am displaying the output in a text widget in the slot 'Print'.

Can anyone please suggest a method to make the application to process the emitted signal immediately.

Thanks,
Subbarao

fezvez
25th June 2010, 14:12
Take a look at : enum Qt::ConnectionType

Basically, when you connect a signal to a slot, you do something like :
connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed()));

But, there is one more parameter the connection type.

If you look at the QObject::connect documentation, you will see that you are looking for this 5th argument : Qt::DirectConnection (documentation extract : The slot is invoked immediately, when the signal is emitted.)

Basically, just type
connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed()), Qt::DirectConnection);

venk2ksubbu
27th June 2010, 13:44
Thank you. I am using QT 3.3 and I have to use this version. I checked the connect function syntax in QT 3.3. I found that there is no fifth argument. I agree that the fifth argument is present in QT ver 4 onwards.

Could you please suggest any other technique if you have please ?

Thanks,
Subbarao

squidge
27th June 2010, 14:09
You can use a metacall.

venk2ksubbu
28th June 2010, 06:40
Could you please give some more clue on metacall.

Thanks,
Subbarao

Lykurg
28th June 2010, 06:45
See QMetaObject::invokeMethod() or QMetaObject::invoke().

venk2ksubbu
28th June 2010, 08:30
But QT 3.3 does not have these functions.

Thanks,
Subbarao

agathiyaa
28th June 2010, 11:37
Hi,

Are you trying to read the output from the process and redirect ??

venk2ksubbu
29th June 2010, 07:10
Yes, I am trying to read the output from a process and then I am trying to dump that output in to a text widget which is part of another class. I cannot access the function of the class which contains the text widget, as my process is started from different class. However the objects of these two classes are created in same class.

Thanks,
Subbarao