Combobox with delete-item buttons at items
-
(as Qt newbie) i'm searching how to create combobox with delete-item buttons at (mostly) all expanded items
i planned base it on check box in combobox example presented here http://qt-project.org/forums/viewthread/7079
but i failed on the fact that createEditor is not called for initially selected item = user must move mouse to another item and back to get createEditor on selected item
than i wanted call createEditor by myself during item-activated signal but i failed to connect on it because it is emitted by combobox's private part = i haven't pointer to itdo you have any solution? thanks
-
If I understood your problem correctly, you want to remove several items from a QComboBox. I think the best solution would be this one:
@
combobox.removeItem(combobox.currentIndex());
@With this code, you would delete the entry that is currently active (shown in the non-expanded field).
-
i want every item will have except standard text also (right-side) image, after click to image/picture/icon it will delete item (= removeItem)
problem is now to handle that click to image (click to text has to be handled standard way = item selection) -
Not that easy. As you can see in the class reference, QComboBox provides these signals:
@
void activated ( int index )
void activated ( const QString & text )
void currentIndexChanged ( int index )
void currentIndexChanged ( const QString & text )
void editTextChanged ( const QString & text )
void highlighted ( int index )
void highlighted ( const QString & text )
@Then, it inherits one from QWidget
@
void customContextMenuRequested ( const QPoint & pos )
@and one from QObject
@
void destroyed ( QObject * obj = 0 )
@There is not a single one to handle mouse clicks. It will be difficult to catch those; it would be easier to make a "delete" button or a "delete" menu entry.
-
I think you can overwrite Paint metod and add "add,edit and delete" items QPicture type After you can connect your items Signal Click from QPicture with your Slots for add, edit and delete items.
But I think it's not easy..... I don't have tested it, but can function
-
[quote author="ArcNexus" date="1356477291"]I think you can overwrite Paint metod and add "add,edit and delete" items QPicture type[/quote]
i see no problem to overwrite QItemDelegate::paint
but what does it mean 'add "add,edit and delete" items QPicture type'? (remember that QItemDelegate::createEditor is not called for actual item, where else i can do it?)p.s. today i found that overwriting QItemDelegate::event it is not called at all
-
[quote author="real name" date="1357133282"]
i see no problem to overwrite QItemDelegate::paint
but what does it mean 'add "add,edit and delete" items QPicture type'?[/quote]Yes, when I say Add,edit and delete i refer to QPicture. But I have not tested it. however i think it should work if you overwrite methods but its not easy.