Results 1 to 3 of 3

Thread: Exchange information between non-qt pthreads and gui thread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    3

    Question Exchange information between non-qt pthreads and gui thread

    Hi,

    I am using Qt for having a nice GUI front-end, while the underlying program doesn't use any QThreads and many objects are not created from the main GUI thread.

    There're several PThreads working in the background, which should be able to interact with the GUI. E.g. a module is watching a UDP-Connection and in certain situations it would be nice to signal the GUI to show a dialog to inform the user about it.

    My first try was to use a dummy QObject in the PThread to signal the GUI (by using the signals and slots from the dummy object). But it seems lead to a fatal error:
    <unknown>: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.

    What happens to signals in general? Which thread is looking for the event queue?
    I guess my assumption, that signals are always handled by the main GUI thread, is wrong.

    Btw. is it a problem that my QObject was created from the PThread?

    How to solve such a problem in the right way? (without rewriting all modules and porting them to QThreads etc.)

    Many thanks for your help!

    J.R.

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

    Default Re: Exchange information between non-qt pthreads and gui thread

    You can use Qt's event system, it is thread-safe. Just use QCoreApplication::postEvent() and handle the event where you need it. You can additionally use event filters.
    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. Commands exchange between Client and Server
    By QAlex in forum Qt Programming
    Replies: 8
    Last Post: 23rd November 2009, 16:59
  2. Using pthreads for a front end
    By kachofool in forum Newbie
    Replies: 1
    Last Post: 5th October 2009, 22:13
  3. QTableWidget row-column exchange
    By SnarlCat in forum Qt Programming
    Replies: 0
    Last Post: 28th August 2008, 13:49
  4. Tolltech greenphone for exchange or sale
    By izico in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 3rd July 2008, 06:15
  5. CMake and pthreads
    By Matt Smith in forum General Discussion
    Replies: 5
    Last Post: 3rd September 2006, 20:42

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
  •  
Qt is a trademark of The Qt Company.