Results 1 to 7 of 7

Thread: how can thread receive data sent by main thread

Hybrid View

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

    Default Re: how can thread receive data sent by main thread

    Quote Originally Posted by Myx View Post
    Qt Code:
    1. label->moveToThread(thread)
    To copy to clipboard, switch view to plain text mode 
    What are you trying to do? You must not touch GUI in a worker thread:
    Quote Originally Posted by docs
    Although QObject is reentrant, the GUI classes, notably QWidget and all its subclasses, are not reentrant. They can only be used from the main thread.
    J-P Nurmi

  2. #2
    Join Date
    Apr 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how can thread receive data sent by main thread

    Quote Originally Posted by jpn View Post
    What are you trying to do? You must not touch GUI in a worker thread:
    just gave a guess but didnt try it this way...
    i made something like this

    Qt Code:
    1. class SerialThread : public QThread
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. SerialThread(QObject *mainGUI, QObject *parent = 0)
    7. {
    8. GUI=mainGUI;
    9. }
    10.  
    11. protected:
    12. void run()
    13. {
    14. connect(GUI,SIGNAL(),this,SLOT());
    15. exec();
    16. }
    17.  
    18. private:
    19. QObject *GUI;
    20.  
    21. (...)
    22. };
    To copy to clipboard, switch view to plain text mode 
    and while creating a thread

    Qt Code:
    1. SerialThread *thread=new SerialThread(this);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Struggling with QThread...
    By TemporalBeing in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2009, 20:46
  2. Replies: 5
    Last Post: 17th January 2008, 21:49
  3. Accessing data from a worker thread
    By steg90 in forum Qt Programming
    Replies: 20
    Last Post: 25th May 2007, 10:20
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. Replies: 10
    Last Post: 20th March 2007, 22:19

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.