Results 1 to 5 of 5

Thread: Gui Painting in Thread?

Hybrid View

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

    Question Gui Painting in Thread?

    Hi All,

    I m using Qt 4.1.5 on my MAC.

    I have a thread in which I m doing somework and also emit signal to add Item in a QTreeWidget.

    My problem is that Item is shown after I click on the treeWidget but I want them to be seen as they added on the treeWidget.


    If some one knows the Issue then plz help me.

    Thanks.

  2. #2
    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: Gui Painting in Thread?

    Looks like the widgets doesn't get updated...

    Could you post the ode for the slot that updates the tree widget? And also some code from the thread would be useful.

    Regards

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

    Question Re: Gui Painting in Thread?

    Actually Main thread class emit signal for update the treeWidget in Gui class...
    some part of code....
    emit UpdateTree(); in thread class

    connect(guiClass,SIGNAL(UpdateTree()),this,SLOT(Sh owTree())); ///in Gui class

    void GuiClass::ShowTree()
    {
    for(int i = 0;i<count;i++)
    {
    QTreeWidgetItem *pItem = new QTreeWidgetItem(/*Gui TreeWidget */);
    pItem->setText(0,"thread");
    }
    }

    that is ok but problem is that whenver new-new treeWidgetItem is created ,,,it is not showing one by one ....whenever i click on treeWidget then it is showing all item at a time.
    I want to show treeItem one by one using thread....sometimes it is not showing properly...
    whenever i activated the treeWidget then it shows all the created TreeItem....

  4. #4
    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: Gui Painting in Thread?

    connect(guiClass,SIGNAL(UpdateTree()),this,SLOT(Sh owTree())); ///in Gui class
    I don't think I understand...
    You have a slot in that is executed in a worker thread that updates a widget?

    I was thinking that the worker thread emits the signal and the GUI thread updates the interface accordingly.
    If this is the case then the slot is executed asynchronously, which might cause a delay before the moment the signal is emitted and the moment the slot gets executed.

    You could try updating the tree widget every time you add a new item to it.
    How do you exactly add the item to the tree widget?

    Regards

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

    Question Re: Gui Painting in Thread?

    Actually I emit a SIGNAL from the Thread and then receive it in the GUI class and add the Item to the treeWidget Like..
    Qt Code:
    1. QTreeWidgetItem *item = new QTreeWidgetItem(myTreeWidget);
    2.  
    3. item->setText(0,some String Coming from theThread);
    4. item->setText(0, other string from theThread);
    5.  
    6. item->setIcon (0, Icon );
    To copy to clipboard, switch view to plain text mode 

    This is a slot in which the string I set in TreeWidgetItem is coming from the Thread class which is stored in the LinkList and when a Item is added to the List in the Thread I emit the signal and update the treeWidget as above.

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. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  3. simple thread layout question
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2006, 11:02
  4. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44
  5. Replies: 2
    Last Post: 6th January 2006, 21:15

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.