Results 1 to 3 of 3

Thread: Accesing widgets from separate thread

  1. #1
    Join Date
    Dec 2008
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Accesing widgets from separate thread

    Hello again everybody.
    Suppose i have a mainwindow with some widgets on it .
    Now i want to create a separate thead and, in it's run() , to access the widgets from the mainwindow .

    How can this be done ?

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Accesing widgets from separate thread

    In one of the recent posts i have read that you cannot access widgets from a separate non-gui thread.
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    Oct 2008
    Location
    Brazil, Sao Paulo - SP
    Posts
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accesing widgets from separate thread

    You could do some interaction between the GUI and a non-GUI thread by using signals/slots. One separated thread could emit a signal changeLabelText(const QString&) thats connected to a QLabel::setText(const QString&) from the GUI-thread, the result is that the label setText call would be enqueued at the GUI thread event queue (it will only be effectively called on the Qt event handling thread, the GUI one).

    Controlling widgets from outside the GUI thread is totally possible with some workarounds (I've implemented a win32 multithreaded GUI library port to linux and mac through Qt).

    Take a look at
    http://doc.trolltech.com/4.4/threads...s-and-qobjects
    for further info.

Similar Threads

  1. new QWidget in separate thread
    By magland in forum Qt Programming
    Replies: 15
    Last Post: 7th February 2008, 12:32
  2. handling paintGL in a separate thread
    By al101 in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2007, 17:04
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. Replies: 10
    Last Post: 20th March 2007, 22:19
  5. Replies: 11
    Last Post: 7th July 2006, 13:09

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.