Results 1 to 7 of 7

Thread: View update problem

  1. #1
    Join Date
    Feb 2006
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default View update problem

    Hi all,

    I have a strange problem, please see the image attached.

    I am using QTreeWidget in all the tabs as shown in the image and my app is multithreaded which constantly updates(adds QTreeWidedItem)in first tab cantaining QTreeWidget . If i does not change the tab all is fine but, if change the tab and come to first tab the update from the thread goes to the column header as shown in the image and strange thing is it does not happen every time i run the appication. I coun'd figure why this is happening, any suggestion ?

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: View update problem

    How does you thread update that widget?

    From Qt docs:
    The child of a QObject must always be created in the thread where the parent was created. This implies, among other things, that you should never pass the QThread object (this) as the parent of an object created in the thread (since the QThread object itself was created in another thread).
    You must ensure that all objects created in a thread are deleted before you delete the QThread. This can be done easily by creating the objects on the stack in your run() implementation.
    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. As noted earlier, QCoreApplication::exec() must also be called from that thread.

  3. #3
    Join Date
    Feb 2006
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: View update problem

    I am using slot to update the view(QTreewidget). All threads sends signals to slot that updates the view. Since slot callback are processed by main thread, i think it is not the thread problem. Any idea ?

    Thanks.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: View update problem

    Quote Originally Posted by prakash
    I am using slot to update the view(QTreewidget).
    Do you send only data or QTreeWidgetItems?

    Quote Originally Posted by prakash
    All threads sends signals to slot that updates the view.
    Do you use queued connections? Does your QThread subclass emit signals?

  5. #5
    Join Date
    Feb 2006
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: View update problem

    Yes my QThread subclass emit signals. When i use widget with setItemWidget() it happens but works fine if i do not use cell widget item.

    QTreeWidgetItem *item = new QTreeWidgetItem(_pView);
    //this works
    item->setText(0,url);
    item->setTextColor(0,QColor(Qt::blue) );
    //but this causes the problem.
    QLabel * widget = new QLabel(url,_pView);
    widget->setCursor(Qt::PointingHandCursor);
    _pView->setItemWidget(item,0, url);

    Thanks.

  6. #6
    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: View update problem

    Quote Originally Posted by prakash
    _pView->setItemWidget(item,0, url);
    Should this be?
    Qt Code:
    1. _pView->setItemWidget(item,0, widget);
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: View update problem

    Quote Originally Posted by prakash
    Yes my QThread subclass emit signals.
    Make sure to add Qt::QueuedConnection all your connections you make with that class.

Similar Threads

  1. Updating directory view in a QListView
    By Cruz in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2009, 23:48
  2. Replies: 6
    Last Post: 20th April 2006, 10:23
  3. hide/show screen update problem
    By SkripT in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2006, 17:49
  4. Problem with screen update...
    By mysearch05 in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2006, 18:24
  5. Record update windowd entered data saving
    By MarkoSan in forum Qt Programming
    Replies: 56
    Last Post: 18th January 2006, 18:50

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.