Results 1 to 4 of 4

Thread: Inserting Item to a QTreeWidget from Thread?

  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Inserting Item to a QTreeWidget from Thread?

    Hi All,

    I m using Qt 4.1.5 on my MAC.
    I have a QTreeWidget in which I want to Insert Item at run time from the Thread.I m calling the function in which I have Insert the Item in the Other Class.

    Actually It is calling the function but could not Insert the Item in the QTreeWidget.

    If anybody knows the Issue then plz help me.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Inserting Item to a QTreeWidget from Thread?

    You can't call GUI-methods from another thread but the main thread !

    If you want to do so, just emit a signal from your secondary thread, and connect it to an "addItem" slot in your TreeWidget class.

    Guilugi.

  3. The following user says thank you to guilugi for this useful post:

    vishal.chauhan (22nd June 2007)

  4. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inserting Item to a QTreeWidget from Thread?

    Quote Originally Posted by guilugi View Post
    You can't call GUI-methods from another thread but the main thread !
    Generally you can call GUI thread methods from worker threads, but extra care must be taken.
    You can't do things that affect in any way the event loop of the main thread. Like drawing on a widget whose paint event is in progress, etc.

    Regards

  5. #4
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Inserting Item to a QTreeWidget from Thread?

    Yup marcel, thanks for clarifying this
    That's what I meant !

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. Replies: 10
    Last Post: 20th March 2007, 22:19
  3. QTreeWidget item editing: want column specificity
    By McKee in forum Qt Programming
    Replies: 12
    Last Post: 10th December 2006, 22:12
  4. Removing items properly from qtreewidget item
    By Djony in forum Qt Programming
    Replies: 6
    Last Post: 21st November 2006, 12:20
  5. Replies: 1
    Last Post: 21st September 2006, 10:37

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.