I am not able to add Close Button in Combobox Item view at right Side, which will act as delete button for the Item. Any one have any idea please help me.
I am not able to add Close Button in Combobox Item view at right Side, which will act as delete button for the Item. Any one have any idea please help me.
There are 2 possibilities I can think of right now, both of which are quite complicated:
1. Subclass QStyledItemDelegate, reimplement createEditor so that it creates the delete button for the second column of a QTableWidget, then use a QTableWidget with that Delegate as the Comboboxes view (with openPersistentEditor)
2. Subclass QComboBox, reimplement paintEvent so that your delete button is painted and reimplement mousePressEvent so you can detect wether the user clicked on the item oder the items delete button rect.
akram.halder (12th August 2010)
Hi ,
I tried your secound Idea. But it draws a close button on combobox. It does not display close button on Items(Right side). Please reffer the below code. Correct me please if I am wrong.
CCustomCombobox::CCustomCombobox(QWidget * parent):
QComboBox(parent)
{
}
void CCustomCombobox:aintEvent(QPaintEvent *pe )
{
QPainter p(this);
QImage closeImage;
image.load(":/resource/Icons/Window_Ctrl_Icon_Close.png");
p.drawImage(100,0,closeImage);
}
Regards,
Akram
Bookmarks