1

I have a list where a user can select an item. The selection runs necessary procedure.

self.listWidget_ITEMS.itemClicked.connect(self.refresh)

def refresh(self, item):
    print 'refresh.item = {}'.format(item)

The problem is: if a user clicks an item, then drag the mouse and only then release, then refresh function catch the clicked item, but not selected (item, where the mouse was released). If there a way to catch selected item?

kiryha
  • 183
  • 1
  • 2
  • 14
  • If you haven't already, take a look at [`supportedDropActions()` for QListWidget](https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/PySide/QtGui/QListWidget.html#PySide.QtGui.PySide.QtGui.QListWidget.itemChanged). If you can't get that to do what you need, maybe look at [`QHoverEvent`'s](https://srinikom.github.io/pyside-docs/PySide/QtGui/QHoverEvent.html) and see if you can build logic into that. – Arda Arslan Aug 31 '17 at 02:22
  • Thanks, Ada! I use PySide.QtGui.QListWidget.itemChanged to solve my issue. – kiryha Aug 31 '17 at 13:07
  • @kiryha. If you want the selected item(s), why not just use `self.listWidget.selectedItems()`? – ekhumoro Aug 31 '17 at 13:10
  • @ekhumoro I need to do something with list items each time user click them. So I use itemClicked() to run this procedure. And then I have the main action, which I run with the button and there I use selectedItems(). So, if user click-select an item in list and press a button everything is fine. But if user click-drag-release item and press a button, then selected item not equal clicked item. – kiryha Aug 31 '17 at 13:54
  • @kiryha. By definition, it is impossible to do click-drag-release in a single operation. A click is mousepress-mouserelease on the same item. So what you actually mean is mousepress-drag-mouserelease - in which case, there is no clicked item (i.e. the `itemClicked` signal is not emitted). – ekhumoro Aug 31 '17 at 16:16

0 Answers0