View Full Version : Add pushbutton to QTreewidgetitem
sudhansu
23rd June 2010, 06:37
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
kemp
23rd June 2010, 06:47
void QTreeWidget::setItemWidget ( QTreeWidgetItem * item, int column, QWidget * widget )
aamer4yu
23rd June 2010, 07:05
Also better if you use delegates for this purpose..
There have been many such questions.. search the forum, you will get the idea..
sudhansu
23rd June 2010, 07:16
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.
sudhansu
23rd June 2010, 08:56
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
class CDelegatePushButton : public QItemDelegate
{
public:
CDelegatePushButton();
~CDelegatePushButton() {}
void paint();
};
CDelegatePushButton::CDelegatePushButton()
{
paint();
}
void CDelegatePushButton::paint()
{
QPushButton *pushButton = new QPushButton;
pushButton->setFixedSize(25,30);
}
and inside my trewwidget class i added like below in constructor
treeWidget->setItemDelegate(testDelegate);
But its not working. Please tell me how to do.
sudhansu
23rd June 2010, 10:39
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
void CreateTree( QString i_strLit)
{
QTreeWidgetItem *ptrTreeChildItem = new QTreeWidgetItem(mytreewidget);;
if(NULL != ptrTreeChildItem)
{
QString strName = i_strLit;
ptrTreeChildItem->setIcon(0, m_studnetIcon);
ptrTreeChildItem->setText(0, strName);
mytreewidget->setItemWidget(ptrTreeChildItem, 1 ,
m_pushButtonMode);
}
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.