Results 1 to 13 of 13

Thread: Problem emiting signal in QTreeWidgetItem's subclass

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    91
    Thanks
    60
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem emiting signal in QTreeWidgetItem's subclass

    Since this is totally new question which has nothing to do with the title of my provious post, I post it here.

    I have subclassed QTreeWidgetItem to MyTreeWidgetItem, which contains an Element* .
    Then how can I know which item in QTreeWidget has been clicked?
    Can I emit a signal like itemSelected(Element*) ?

    I used to subclass the QGraphicsrectItem and emit a signal contains this Element* like this,

    Qt Code:
    1. class MyRectItem : public QObject, public QGraphicsRectItem
    2. {
    3. Q_OBJECT
    4. public:
    5. ...
    6. Element* pE;
    7. signals:
    8. void itemisSelected(bool newState);
    9. void itemSelected(Element* pE);
    10. protected:
    11. QVariant itemChange(GraphicsItemChange change, const QVariant &value)
    12. {
    13. if (change == QGraphicsItem::ItemSelectedChange)
    14. {
    15. bool newState = value.toBool();
    16. if (newState == true)
    17. {
    18. emit itemisSelected(newState);
    19. }
    20. }
    21. return QGraphicsItem::itemChange(change, value);
    22. }
    23. };
    To copy to clipboard, switch view to plain text mode 
    I connected the signal itemisSelected(bool) with signal itemSelected(Element*) right after I new a MyRectItem. And it works well.

    Is there any similar way to emit a signal(Element*) or signal(MyTreeWidgetItem*) in MyTreeWidgetItem?
    Last edited by Shawn; 3rd September 2007 at 18:59.

Similar Threads

  1. Replies: 3
    Last Post: 15th April 2007, 19:16

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.