[Qt-interest] How to make QWidget move with QTreeWidgetItem that contains it ?

jialrs jialrs at 126.com
Wed Jul 7 02:22:21 CEST 2010


i am sorry ,there is something wrong with my e-mail client , now i sent it again ....
Hello eveyone , i am frustrated by the QTreeWidgetItem , i has find some wondering problem;
i want to realise a function that can move QTreeWidgetItem up or down , this to say change the
position of the items; 
But i find , when a QWidget in the item's cell, if i move it , for example i  remove the item 
and then insert back, the QWidget was disappeared :-(
i has no idea but to store the item object, so that after insert the item back, i can set the
Widget again, but, to my disappointment , the pointer i has stored become invalid even i hasn't 
remove the widget :-(
and i find , i can't set the same widget again to a QTreeWidget, because i can't see it ,
this the source code("this" is a QTreeWidget object):

    QTreeWidgetItem *ch = this->currentItem();
    QTreeWidgetItem *pa = ch->parent();
    QProgressBar * qbar = this->itemWidget(ch,3);
    this->removeItemWidget(ch,3);
    pa->removeChild(ch);
    pa->insertChild(1,ch);
    this->setItemWidget(ch,3,qbar);

i know there is a QProgressBar in item "ch", because the row is more higher than others
i want to know how the QTreeWidget stores the QWidget (QProgressBar) , and why sometimes 
the pointer i stored becomes invalid , and how can i move an items with the widget going

does anyone can help me ?

by jialrsHow to make QWidget move with QTreeWidgetItem that contains it ?

Hello eveyone , i am frustrated by the QTreeWidgetItem , i has find some wondering problem;
i want to realise a function that can move QTreeWidgetItem up or down , this to say change the
position of the items; 
But i find , when a QWidget in the item's cell, if i move it , for example i  remove the item 
and then insert back, the QWidget was disappeared :-(
i has no idea but to store the item object, so that after insert the item back, i can set the
Widget again, but, to my disappointment , the pointer i has stored become invalid even i hasn't 
remove the widget :-(
and i find , i can't set the same widget again to a QTreeWidget, because i can't see it ,
this the source code("this" is a QTreeWidget object):

    QTreeWidgetItem *ch = this->currentItem();
    QTreeWidgetItem *pa = ch->parent();
    QProgressBar * qbar = this->itemWidget(ch,3);
    this->removeItemWidget(ch,3);
    pa->removeChild(ch);
    pa->insertChild(1,ch);
    this->setItemWidget(ch,3,qbar);

i know there is a QProgressBar in item "ch", because the row is more higher than others
i want to know how the QTreeWidget stores the QWidget (QProgressBar) , and why sometimes 
the pointer i stored becomes invalid , and how can i move an items with the widget going

does anyone can help me ?

by jialrs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100707/8b0fcb2e/attachment.html 


More information about the Qt-interest-old mailing list