1
votes

I implement a pop up list with QListWidget. But I found that the selection of list is done when mouse pressed on an item. But what I would like to is selection on click. How can I change it? (without delegate)

Update:

I have a subclass of QListWidget. The selection of this list is done (emit of signal, change of selectedItems(), change of Qss QListWidget::item:selected{} etc.) when I hold the left button on an item. What I want is make these changes when release mouse on an item, not press and hold on it.

1
subclassing QListWidgetniyou
@niyou Yes, that's what I did. But how can I control the selection behavior.Mike Shaw

1 Answers

0
votes

QListWidget has the functions setSelectionMode and setSelectionBehaviour. If this is not what you're looking for, please explain more clearly what you're trying to achieve.

In response to the update of the question, you would need to handle the mouse events of the widget to prevent selection when the mouse down event occurs (don't call the base class function) and then deal with setting the selection yourself, in response to mouse release events.

As QListWidget is a convenience class with an internal model, you'd be better off using QListView, which allows you to manipulate its selection model.

If you decide to do this, make sure there is a good reason for it, as users expect a list widget to work in a particular way and changing this is likely to simply annoy the user.