Results 1 to 9 of 9

Thread: How to make the application to process signals immediately

  1. #1
    Join Date
    Sep 2007
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default How to make the application to process signals immediately

    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

  2. #2
    Join Date
    Jun 2010
    Location
    France
    Posts
    7
    Qt products
    Qt4 Qt Jambi
    Platforms
    Unix/X11 Windows
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: How to make the application to process signals immediately

    Take a look at : enum Qt::ConnectionType
    Basically, when you connect a signal to a slot, you do something like :
    Qt Code:
    1. connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed()));
    To copy to clipboard, switch view to plain text mode 

    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
    Qt Code:
    1. connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed()), Qt::DirectConnection);
    To copy to clipboard, switch view to plain text mode 
    Last edited by fezvez; 25th June 2010 at 15:19.

  3. #3
    Join Date
    Sep 2007
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make the application to process signals immediately

    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

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: How to make the application to process signals immediately

    You can use a metacall.

  5. #5
    Join Date
    Sep 2007
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make the application to process signals immediately

    Could you please give some more clue on metacall.

    Thanks,
    Subbarao

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: How to make the application to process signals immediately


  7. #7
    Join Date
    Sep 2007
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make the application to process signals immediately

    But QT 3.3 does not have these functions.

    Thanks,
    Subbarao

  8. #8
    Join Date
    Jun 2010
    Location
    India
    Posts
    50
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1
    Thanked 15 Times in 14 Posts

    Default Re: How to make the application to process signals immediately

    Hi,

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

  9. #9
    Join Date
    Sep 2007
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make the application to process signals immediately

    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

Similar Threads

  1. Replies: 3
    Last Post: 6th January 2010, 17:55
  2. emit make process more slowly ?
    By wirasto in forum Qt Programming
    Replies: 3
    Last Post: 31st December 2009, 17:51
  3. Replies: 3
    Last Post: 4th March 2008, 09:35
  4. can't make QAbstractItemView signals work
    By ber_44 in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2007, 08:29
  5. Module to process application parameters
    By Opilki_Inside in forum General Programming
    Replies: 4
    Last Post: 9th February 2007, 00:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.