PyQt doesn't understand &
-
@user4592357
Hmm, although I don't use them myself, I concur. My code is a little different:self.actionCases = QtWidgets.QAction("&Cases", self) ... self.toolbar = QToolBar() self.toolbar.addAction(self.actionCases)
"&Cases"
does not show theC
underlined."&&Cases"
shows as&Cases
, so it's doing some ampersand-parsing. I'm Linux. Maybe it's not supposed to do anything on Linux? What are you? I have to doubt whether this is a Python/PyQt issue... -
there's another weird error that bothers me. whenever i import a class, for example:
from PyQt5.QtCore import QObject
i get this error:
E0611:No name 'QObject' in module 'PyQt5.QtCore'
same goes for all
Qt
classes. -
Then again: which version of PyQt5 and Qt 5 are you using ?
How did you installed them ? -
from PyQt5.QtCore import QObject
This should indeed work for you. If it does not, I do not see how you can use any PyQt stuff at all! It is not related to the menu
&
issue.I am:
PyQt version: 5.7 Qt version: 5.7.1 SIP version: 4.18.1
Firstly, you say you are Qt
5.10
but PyQt4.19
. Therein lies your problem, for the imports at least. You must use a PyQt version matching your Qt version, and PyQt 4.x will not work for Qt version 5.x!!(Gosh, I just noticed my own SIP is way behind yours. Doesn't seem to have hindered me anywhere. Does SIP version matter much?)
Secondly, you used
pip3
to install PyQt. I had nothing but grief withpip3
, and never used it. If you are saying you did apip3 install pyqt5
and ended up with PyQt version 4.x, clearly something did not work correctly... Is it possible you have an older PyQt 4 lying around on your machine?@SGaist
I would not mind a comment on why --- for me at least, with correct Qt 5 / PyQt 5 --- I do not get accelerator key visual or behaviour with&...
menu item? -
@user4592357
So you are saying you are using PyQt 4.19.7 against Qt 5.10.0?
Plus, you did an install ofpip3 install pyqt5
and you got PyQt 4.19.7?If this really is the case, you should not be surprised that things don't work/appear right.
-
@user4592357
I don't know, 'coz like I said I never got on with pip3.TBH, if you're saying you code actually works, I'd be surprised if it could run against PyQt4 at all. I wonder where you think you have PyQt 4 from in the first place? In my actual code I use
from PyQt5.Qt import PYQT_VERSION_STR
to get it, so you know what your code is actually using. Andfrom PyQt5.QtCore import QT_VERSION_STR
for Qt version. -
Not sure if this helps and it has nothing to do with the version of PyQt but in Windows you need to use the ALT key to bring up the underline letter used with the “&” symbol.
It’s referenced in this SO question and answer
-
@user4592357
Look, I really don't where you are. But If you usedpip3 install pyqt5
and you got PyQt4 something is really wrong. And if it did get PyQt5 but somehow your code only finds PyQt4 you are equally in a mess. So you need to sort this out before you go any further.... -
He said he was using:
SIP version: 5.10
PyQt version: 4.19.7I think he just switched those two around and is confused. The most current version of SIP is 4.19.7 and the most current version of PyQt is 5.10. There never has been a version of PyQt4 with that version number nor has SIP gotten to that version number yet.
-
i know it's hard to guess but it's 'she' :)
btw this happens on my new laptop where i only installed qt 5.10.1 and then pyqt5.
but the same happened also on my former laptop where i had qt4 and installed pyqt5.i have no idea what's going on
anyways, i downloaded the sources and wannabuild. got the following:
$ python configure.py Error: Use the --qmake argument to explicitly specify a working Qt qmake.
python.exe .\configure.py --qmake C:\Qt\Qt5.10.1\5.10.1\msvc2015_64\bin\qmake .exe Querying qmake about your Qt installation... Determining the details of your Qt installation... Error: Failed to determine the detail of your Qt installation. Try again using the --verbose flag to see more detail about the problem.
-
What do you get if you make it verbose ?
By the way, you may avoid much of the hassle by using pip/pip3 do install PyQt5.
-
@SGaist
i installled using the command at first place when i got all this mess.
and this is --verbosepython.exe .\configure.py --qmake C:\Qt\Qt5.10.1\5.10.1\msvc2015_64\bin\qmake .exe --verbose Querying qmake about your Qt installation... Determining the details of your Qt installation... C:\Qt\Qt5.10.1\5.10.1\msvc2015_64\bin\qmake.exe -o cfgtest_QtCore.mk cfgtest_QtCore.pro Project ERROR: Cannot run compiler 'cl'. Output: =================== =================== Maybe you forgot to setup the environment? Error: Failed to determine the detail of your Qt installation. Try again using the --verbose flag to see more detail about the problem.
-
From the looks of it, you're doing that from a console that's not configured to use Visual Studio 2015. You should either call the vcvars script with the correct parameters or start the console through the Visual Studio start menu.
-
@SGaist
i opened vs native tools x64 cmd and run the install command - same output.i run
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\vsdevcmd\ext\vsvars.bat
from vs tools->command prompt menu, then run the install command - same output.EDIT: i uninstalled current version and installed with
pip install PyQt5
(and notpip3
, as before) and got the lastest versions:Qt version: 5.10.0 SIP version: 4.19.7 PyQt version: 5.10
but:
pylint errors about imports aren't gone
the letter isn't still underlined. it's how @KevinKSyd said - only shows on alt key press