Results 1 to 19 of 19

Thread: Fast updation for controls in QT3

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    Yes I'm using pthread, I'm passing the main window object (which having 150 line edits) to the thread, and updating the line edits from the threads.

    I have tried using QThread, which also showing the same issue.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Fast updation for controls in QT3

    Read this carefully: http://doc.trolltech.com/3.3/threads.html

    Especially the part that says you can't touch the GUI from a non-GUI thread.
    Last edited by jacek; 8th September 2008 at 14:05. Reason: fixed Qt version in the link

  3. #3
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    I tried with the QThread also, which is not working. I am uploading the sample program, that I have done using QThread. Thanks in Advance .....
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Fast updation for controls in QT3

    Could you repeat my previous post with your own words?

  5. #5
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    Thanks a lot for that the XLib problems are not coming for QThread. But a new problems arise, if I'm using (for the samples I've attached in my previous post) QThread the main window is not coming properly (It's getting hanged), in the document also I could not get any solution for this, can anybody help me ?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Fast updation for controls in QT3

    Quote Originally Posted by soumyadeep_pan View Post
    if I'm using (for the samples I've attached in my previous post) QThread the main window is not coming properly
    You can't mix threads and GUI.

  7. #7
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    To my orginal problem, can I do parallel GUI updation in QT ? Is there any way to do parallel processing with continuous parallel updation GUI in QT? thanks in advance .

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Fast updation for controls in QT3

    Quote Originally Posted by soumyadeep_pan View Post
    To my orginal problem, can I do parallel GUI updation in QT ? Is there any way to do parallel processing with continuous parallel updation GUI in QT?
    You would know that if you read that document I've pointed you to. You can use threads for processing, but only the main thread can do anything with the GUI.

  9. #9
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Question Re: Fast updation for controls in QT3

    Quote Originally Posted by jacek View Post
    only the main thread can do anything with the GUI.
    What do you mean by a main thread ? Can I do any semaphore post to that thread ?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Fast updation for controls in QT3

    Quote Originally Posted by soumyadeep_pan View Post
    What do you mean by a main thread ?
    The main thread (a.k.a. the GUI thread) is the one that created the QApplication instance.

    Quote Originally Posted by soumyadeep_pan View Post
    Can I do any semaphore post to that thread ?
    Typical way of communication between worker threads and the GUI thread is to use custom events. QApplication provides some locking mechanism, but custom events are better.

  11. #11
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    Quote Originally Posted by jacek View Post
    The main thread (a.k.a. the GUI thread) is the one that created the QApplication instance.
    As I'm creating QApplication instance in main(), so I have to update in that thread (a.k.a Inside main() or any called functions from main()), but to my orginal problem I have to update some controls continuosly, as the following -

    main ()
    {
    QApplication object;

    while (1)
    {
    //Updation for the controls.
    }

    object.exec();
    }

    I assume this algorithm will successfully update controls, but it will be always in while loop and I'll not get any events from the other controls available in the same window. If I'm correct, can anybody suggest a solution for this ? ..thanks in advance ....

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Fast updation for controls in QT3

    Use QTimer to fire a slot at given interval. You don't have to update faster than people can see.

  13. The following user says thank you to jacek for this useful post:

    soumyadeep_pan (19th September 2008)

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.