Skip to content
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

Why can't I import QAction normally using qtpy? #474

Open
npzs opened this issue Jan 27, 2024 · 1 comment
Open

Why can't I import QAction normally using qtpy? #474

npzs opened this issue Jan 27, 2024 · 1 comment

Comments

@npzs
Copy link

npzs commented Jan 27, 2024

python: 3.12/3.11.7 embedded version
Pyqt: 5.15.10/5.15.9
qtpy:2.4.1
Editor: vscode
I used the embedded version + venv to create a virtual environment. After discovering the problem, I tried to remove the virtual environment and tried changing to different versions of python and pyqt, but the problem remained.
As you can see in vscode, when I use qtpy to import, QAction cannot be recognized normally, but other subclasses are normal, such as QApplication and QMainWindow. There is no problem.
But if you do not use qtpy and import directly from pyqt5, then everything will be normal, including QAction.
How to solve this?
f98e1d4fefa8438fbfc96df6a58acdfd
fe0b5160a2e947dd9b13ecdd5016c43f

kohei-noda-qcrg added a commit to RQC-HU/dcaspt2_input_generator that referenced this issue Feb 3, 2024
Autocomplete for classes such as qtpy.QtWidgets.QAction does not work with the PyQt
ref. spyder-ide/qtpy#474 .
@dalthviz
Copy link
Member

dalthviz commented Apr 9, 2024

Hi @npzs thank you for the feedback! When you say importing QAction is not working you mean like VSCode is not highlighting QAction in the import, right? Or maybe that running the code gives some error? Do you have any other binding other than PyQt5 installed? Maybe that could be causing VSCode to not highlight properly the code?

My guess is that maybe some sort of config needs to be done over VSCode/Pylance like the one documented for type checking (https://github.com/spyder-ide/qtpy?tab=readme-ov-file#type-checker-integration) but not sure to be honest.

Any new info to better understand this is appreciated. Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants