Results 1 to 6 of 6

Thread: Problem updating Line edit from a thread

  1. #1
    Join Date
    Feb 2007
    Posts
    63
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Problem updating Line edit from a thread

    I have a QT application in which i am calling a thread .
    In the thread i am calling a function to update a lineEdit box dynamically based on certain conditions.

    But the problem is that when i run the application for some time , it hangs showing error "xlib: unexpected async reply (sequence.......).

    I searched for this error and found that i cannot update GUI from a thread.

    But my application needs a thread and gui to be updated dynamically.

    How can i do this.
    ???????

    Regards

    Raghvendra

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem updating Line edit from a thread

    You can't update any gui element from outside the main-thread. You have to change your code to do updates only in mainthread (e.g. by using signals/slots to carry the data to the mainthread).

  3. #3
    Join Date
    Feb 2007
    Posts
    63
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Problem updating Line edit from a thread

    actually i am new to qt.
    by main thread do you mean that i should call the function in the main program i.e from where i am calling the thread?


    Plz let me know

    Regards

    Raghvendra

  4. #4
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem updating Line edit from a thread


  5. #5
    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: Problem updating Line edit from a thread

    Signals and slots are not thread-safe in Qt 3. Use custom events to deliver data to main GUI thread. See Thread-safe Event Posting.
    J-P Nurmi

  6. #6
    Join Date
    Feb 2007
    Posts
    63
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Problem updating Line edit from a thread

    Thanks very much


    i have used the customevent and my problem is now solved

Similar Threads

  1. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 09:16
  2. Line Edit Controll problem
    By mansoorulhaq in forum Qt Programming
    Replies: 5
    Last Post: 31st October 2007, 08:33
  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. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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.