Unsolved QComboBox with a star icon to "pin" favorites
Imagine you have a 50+ items QComboBox and most of the time you use the same 3 items.
I would like to show a star icon ⭐when hovering on a list item, clicking this star will mark the item as a favorite and show it at the beginning of the list.
I think I know how to show favorites on top, once they are marked.
But I'm not sure where to start in order to display the ⭐icon on the right side of currently hover item and receive an event when this ⭐is clicked.
It seems the way to go would be to write my own ItemDelegate, is that correct?
As anything similar (with other kind of QWidgets) already be done? I found QComboBox with checkboxes but they use a checkable property
Thanks in advance
Sounds like a job for a custom QStyledItemDelegate.
Thangs @SGaist I'm currently looking at examples here and there.
To provide custom editing, there are two approaches that can be used. The first approach is to create an editor widget and display it directly on top of the item. To do this you must reimplement createEditor() to provide an editor widget, setEditorData() to populate the editor with the data from the model, and setModelData() so that the delegate can update the model with data from the editor.
The second approach is to handle user events directly by reimplementing editorEvent().
Will I be able to enter editor mode on mousehover if I go with solution one?
With solution2 the difficult part seems to be able to prevent the QComboBox to collapse when the star is clicked, and properly retrieve clicks on the star