Maya 2020 Qt

Maya 2020 Qt

Anonymous
Not applicable
7,697 Views
4 Replies
Message 1 of 5

Maya 2020 Qt

Anonymous
Not applicable

So I load up 2020 and try to run some tools I had written in Python for 2018 and I get this error:

 

No module named Qt #

 

So I do a quick test and notice this:

 

In 2018:

From Qt import QtGui

 

In 2020:

From qt import QtGui

 

So it seems that the Qt library is now named qt with a lowercase Q?  Is this correct?  Why the hell would Autodesk do this?  Seems like an arbitrary name change that messes up a lot of code.

Accepted solutions (1)
7,698 Views
4 Replies
Replies (4)
Message 2 of 5

zewt
Collaborator
Collaborator

I'm confused, what QT module are you importing?  Maya doesn't have a "Qt" (or "qt") module, the Python modules are PySide2...

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

It is actually.  

 

https://help.autodesk.com/view/MAYAUL/2017/ENU/?guid=__files_GUID_3F96AF53_A47E_4351_A86A_396E7BFD66...

 

Try running this in a python in the script editor

 

from Qt import QtGui

 

0 Likes
Message 4 of 5

Anonymous
Not applicable
Accepted solution

I was finally able to track down a solution.  When I started using the QT modules, PySide wasn't fully supported with Maya.  But now it is and they're on PySide2 with the latest versions.  So I've adapted my code:

 

version = cmds.about(version=True)
if int(version) < "2019":
    from Qt import QtCore, QtWidgets, QtGui
else:
    from PySide2 import QtCore, QtWidgets, QtGui
Message 5 of 5

david.oberst
Contributor
Contributor

As far as I know (and I checked Maya2018 on Windows), there is no "Qt" module that you can import.

Is there any chance you somehow installed this little Qt.py shim package somewhere on your PYTHONPATH?  That would give you a Qt to import from.  Try doing this in your 2018 where you are able to import from Qt:

import Qt
print Qt.__file__

which will show you the path to wherever that Qt module is living.  My guess is that it is the shim - it was designed for situations like this where you might need to import from various Qt versions (PySide, PySide2, PyQt4, PyQt5).