name 'QtGui' is not defined - but it is!

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: name 'QtGui' is not defined - but it is!

Post by mlampert »

wmayer wrote:Actually I don't see any need to implement a translate() function. It would suffice to directly use QCoreApplication.translate where the third and fourth parameter is omitted to be source compatible with Qt5.
So you're saying the try:except: block is redundant?
And it is OK to import QtGui even if FreeCAD is run without an UI?
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: name 'QtGui' is not defined - but it is!

Post by wmayer »

So you're saying the try:except: block is redundant?
The whole implementation is redundant.
And it is OK to import QtGui even if FreeCAD is run without an UI?
That's not a problem because the translation facility is part of the QtCore module and not QtGui. For any reason most of the coders use QtGui.QApplication but the translate() function is part of the base class in QtCore.QCoreApplication.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: name 'QtGui' is not defined - but it is!

Post by mlampert »

wmayer wrote:
So you're saying the try:except: block is redundant?
The whole implementation is redundant.
And it is OK to import QtGui even if FreeCAD is run without an UI?
That's not a problem because the translation facility is part of the QtCore module and not QtGui. For any reason most of the coders use QtGui.QApplication but the translate() function is part of the base class in QtCore.QCoreApplication.
Great, I didn't know that and I'm certainly guilty of copying and pasting that construct - and that shall stop now! Thanks!
Post Reply