Results 1 to 2 of 2

Thread: QThread, QMessageBox, gui thread

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QThread, QMessageBox, gui thread

    Hello all,

    simple question: I'm in a thread and would like to pop up a QMessageBox, how do I do it?
    At the moment I get a crash which says that widgets must be created in the Gui thread. My thread can take minutes (or hours) and will need to tell the user if something is not happening properly - any suggestions?

    thanks
    K

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QThread, QMessageBox, gui thread

    You will have to, the way or other, deliver the message to the main GUI thread and show a message box there. As the error provided by Qt states, all widgets must be created in the main GUI thread. The same goes for modifying the GUI.

    If you just want to show and error message in a non-interactive way, meaning the the user cannot choose anything, it should be pretty much simple to emit a signal from the thread with the error message as a parameter and then show it in the GUI thread.
    J-P Nurmi

Similar Threads

  1. How can I get the thread ID out of QThread
    By Artschi in forum Qt Programming
    Replies: 9
    Last Post: 8th November 2017, 03:27
  2. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  3. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44
  4. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55
  5. QMessageBox and threads
    By vfernandez in forum Qt Programming
    Replies: 3
    Last Post: 5th February 2006, 17:24

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.