-
-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Differences in QEvent subclass APIs in PyQt6 cause attribute and/or type errors #394
Labels
Milestone
Comments
Hi @ArthurGW thank you for the feedback! That sounds like a good idea 👍 If you want to help us implementing the mappings let us know! |
StSav012
added a commit
to StSav012/qtpy
that referenced
this issue
Feb 13, 2023
StSav012
added a commit
to StSav012/qtpy
that referenced
this issue
Feb 17, 2023
StSav012
added a commit
to StSav012/qtpy
that referenced
this issue
Feb 17, 2023
StSav012
added a commit
to StSav012/qtpy
that referenced
this issue
Feb 17, 2023
StSav012
added a commit
to StSav012/qtpy
that referenced
this issue
Feb 17, 2023
CAM-Gerlach
added a commit
that referenced
this issue
Feb 23, 2023
* Might close #394 * Rephrase a comment, as @CAM-Gerlach suggested * Test the fix for #394 * Format the docstring as suggested by @CAM-Gerlach * Ensure the created window is of sufficient size to point at * Don't wait before moving and clicking the mouse. `QMainWindow.show()` finishes when the window appears. So, no extra waiting needed. * Don't close the window at the end Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
StSav012
added a commit
to StSav012/qtpy
that referenced
this issue
Feb 23, 2023
StSav012
added a commit
to StSav012/qtpy
that referenced
this issue
Mar 23, 2023
StSav012
added a commit
to StSav012/qtpy
that referenced
this issue
Mar 24, 2023
StSav012
added a commit
to StSav012/qtpy
that referenced
this issue
Mar 24, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example, my application uses qtconsole, which in turns uses QtPy. At one point, qtconsole does:
However, when running PyQt6, the method
QMouseEvent.globalPos()
has been removed (as it has also been removed in Qt6 itself). Simply changing to callQMouseEvent.globalPosition()
doesn't work, as the return type of that is different,QPoint
(old) v.s.QPointF
(new).This is particularly annoying as most event classes used to have the same API -
pos
andglobalPos
returningQPoint
, sometimesposF
etc. for a floating version. Now in Python you have to do a load of type checks when you have a method that handles multiple event types. In C++ this would be spotted at compile time, which is probably why the Qt devs thought it was a reasonable change to make.I would propose mapping this method similar to how e.g.
QFontMetrics.width
is, by monkey patching it directly onto the class object after import. i.e.:QMouseEvent.globalPos = lambda self: self.globalPosition().toPoint()
There may be other missing methods, for example
QMouseEvent.pos()
doesn't actually exist in Qt6 but is defined in PyQt6 anyway - I don't know whether it exists in PySide6.The text was updated successfully, but these errors were encountered: