Results 1 to 5 of 5

Thread: Classic GUI and threading issue

  1. #1
    Join Date
    Nov 2007
    Posts
    24
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Classic GUI and threading issue

    Hi,

    As I can read, to do the right thing with QT and GUI threading, we have to :
    1. Create a new thread (I already have my MainWindow)
    2. Compute inside this thread all the "heavy stuff"
    3. Then sending a signal to main GUI thread (MainWindow) to do the all rendering/widget update.

    Right, but I still don't understand how, in this same main thread, my main window will not freeze If I do important graphics updates

    To give you an example :
    In the Mandelbrot Qt sample, in the rendering function (updatePixMap()), if I insert a very time consuming code, all the main window still frozen !?
    (eg I cannot move my window !?)

    Is it possible to avoid this ?

    Thanks.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Classic GUI and threading issue

    do expensive operations outside of the main thread... It's that simple.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Nov 2007
    Posts
    24
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Classic GUI and threading issue

    Not a bad idea, indeed

    I wish I could get it just like Delphi does with its thread "Synchronize" method (VCL isn't thread-safe too)

    Thanks anyway.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Classic GUI and threading issue

    c++11 has simple threads and QThread is pretty simple to use as well.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Classic GUI and threading issue

    This is also an almost mandatory lecture with these kinds of questions: [wiki]Keeping the GUI Responsive[/wiki].
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Classic GUI and threading issue
    By stef13013 in forum Qt Programming
    Replies: 2
    Last Post: 3rd August 2012, 15:59
  2. Threading issue in DLL
    By CristonDK in forum Qt Programming
    Replies: 6
    Last Post: 15th June 2012, 18:07
  3. Replies: 1
    Last Post: 29th September 2011, 19:20
  4. Threading...?
    By sekatsim in forum Qt Programming
    Replies: 12
    Last Post: 10th June 2008, 01:14
  5. Threading Issue
    By noufalk in forum Qt Programming
    Replies: 4
    Last Post: 4th August 2007, 13:45

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.