Results 1 to 6 of 6

Thread: GUI in more then one thread.

  1. #1
    Join Date
    Feb 2007
    Location
    Wroclaw, Poland
    Posts
    72
    Thanks
    6
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default GUI in more then one thread.

    In some situations I would like to split GUI in two threads - one (main) for general processing, second for creation of time-consuming widget. They could be created in background, when user sees only start widget. I assume that I have at least few second before he decide to change tab or call other dialog - they could be created in this second thread.
    Unfortunately - first experiments shows that I cannot add widget to other in other thread. During signal/event processing (like doLayout or updates) program crash with info - cannot do that in two different threads.

    is there any possibility to do this?

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

    Default Re: GUI in more then one thread.

    GUI processing should be done in the main thread only.

  3. #3
    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: GUI in more then one thread.

    You can render to a QImage in a worker thread and then you can render the result to the widget in the main thread.
    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.


  4. #4
    Join Date
    Feb 2007
    Location
    Wroclaw, Poland
    Posts
    72
    Thanks
    6
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: GUI in more then one thread.

    My concerns lies in time-consuming creation process of Persistent editors. In my project I create them on third tab, so they are not visible at the start. But when user decides to show this tab - GUI freezes when they are created/shown.
    So I would like to send creation of those editors in background so they wouldn't freeze GUI.

  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: GUI in more then one thread.

    You can't. And even if you could, it wouldn't help anything. It's not creation of those widgets that makes your gui slow. You can ask faldżip, on this forum he is probably the most experienced person in this subject
    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.


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

    Default Re: GUI in more then one thread.

    Why not create those editors at startup and then just show them when necessary? Then when someone clicks on the tab it will be instant.

Similar Threads

  1. Replies: 9
    Last Post: 28th November 2009, 20:31
  2. Replies: 16
    Last Post: 7th October 2009, 08:17
  3. Replies: 6
    Last Post: 29th April 2009, 18:17
  4. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31
  5. Main thread - worker thread communication.
    By kikapu in forum Newbie
    Replies: 25
    Last Post: 23rd May 2007, 22:09

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.