fix: AttributeError: 'QMouseEvent' object has no attribute 'pos' (#1598)

* fix: AttributeError: 'QMouseEvent' object has no attribute 'pos'

```
Caught exception:
Traceback (most recent call last):
  File "D:\Python\Python39\lib\site-packages\aqt\browser\sidebar\tree.py", line 328, in mouseReleaseEvent
    if (index := self.currentIndex()) == self.indexAt(event.pos()):
d
```

* fix:   AttributeError: 'QMouseEvent' object has no attribute 'pos'
This commit is contained in:
qxo 2022-01-16 13:29:04 +08:00 committed by GitHub
parent 7af4d30c56
commit 90da6a8885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -325,7 +325,11 @@ class SidebarTreeView(QTreeView):
self.tool == SidebarTool.SEARCH
and event.button() == Qt.MouseButton.LeftButton
):
if (index := self.currentIndex()) == self.indexAt(event.pos()):
if qtmajor == 5:
pos = event.pos() # type: ignore
else:
pos = event.position().toPoint()
if (index := self.currentIndex()) == self.indexAt(pos):
self._on_search(index)
def keyPressEvent(self, event: QKeyEvent) -> None: