Results 1 to 6 of 6

Thread: Add pushbutton to QTreewidgetitem

  1. #1
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Add pushbutton to QTreewidgetitem

    Hi All,

    how to add a pushbutton to treewidgetitem.

    I've a treewidget item and i need to add a pushbutton at end. Please tell me.
    like icon,Text,Pushbutton

    Thank u all.
    Regards,
    Sudhasnu

  2. #2
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Add pushbutton to QTreewidgetitem

    void QTreeWidget::setItemWidget ( QTreeWidgetItem * item, int column, QWidget * widget )

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Add pushbutton to QTreewidgetitem

    Also better if you use delegates for this purpose..
    There have been many such questions.. search the forum, you will get the idea..

  4. #4
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Add pushbutton to QTreewidgetitem

    Thank you very much, But the button is updating over text. I need the button to be created after text, so that i ca update an image.

  5. #5
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Add pushbutton to QTreewidgetitem

    Quote Originally Posted by aamer4yu View Post
    Also better if you use delegates for this purpose..
    There have been many such questions.. search the forum, you will get the idea..
    Thank u very much. Can u plz tell me how to add it. I searchd in forum , but didn't get satisfectory post.

    Below is my implimentation

    Qt Code:
    1. class CDelegatePushButton : public QItemDelegate
    2. {
    3.  
    4. public:
    5. CDelegatePushButton();
    6. ~CDelegatePushButton() {}
    7.  
    8. void paint();
    9.  
    10. };
    11.  
    12. CDelegatePushButton::CDelegatePushButton()
    13. {
    14. paint();
    15. }
    16.  
    17. void CDelegatePushButton::paint()
    18. {
    19. QPushButton *pushButton = new QPushButton;
    20. pushButton->setFixedSize(25,30);
    21. }
    To copy to clipboard, switch view to plain text mode 

    and inside my trewwidget class i added like below in constructor

    Qt Code:
    1. treeWidget->setItemDelegate(testDelegate);
    To copy to clipboard, switch view to plain text mode 

    But its not working. Please tell me how to do.

  6. #6
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Add pushbutton to QTreewidgetitem

    Hi All,

    till now i'm stuck into same proble. Cannt find out hoe to do. Please help me.

    My requirment is like I've a tree widget, I've 2 create items like
    Image text push button
    ------ ---- ------
    Icon "A" pushbutton
    Icon "B" pushbutton
    Icon "C" puchbutton

    below is mycode

    Qt Code:
    1. void CreateTree( QString i_strLit)
    2. {
    3. QTreeWidgetItem *ptrTreeChildItem = new QTreeWidgetItem(mytreewidget);;
    4.  
    5. if(NULL != ptrTreeChildItem)
    6. {
    7. QString strName = i_strLit;
    8. ptrTreeChildItem->setIcon(0, m_studnetIcon);
    9. ptrTreeChildItem->setText(0, strName);
    10.  
    11. mytreewidget->setItemWidget(ptrTreeChildItem, 1 ,
    12. m_pushButtonMode);
    13. }
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. can you draw over a pushbutton?
    By illuzioner in forum Qt Programming
    Replies: 4
    Last Post: 30th August 2017, 08:14
  2. How to get pushbutton as an icon
    By Pembar in forum Newbie
    Replies: 1
    Last Post: 12th May 2009, 19:59
  3. Pop-up Calendar From Pushbutton
    By wagmare in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2009, 05:54
  4. Enlarge Pushbutton?
    By triperzonak in forum Qt Programming
    Replies: 7
    Last Post: 20th June 2008, 14:58
  5. why pushbutton moving??
    By Shuchi Agrawal in forum Qt Tools
    Replies: 7
    Last Post: 19th January 2007, 17:17

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.