Can't import Qt for Python in Maya - qt

I am trying to build a small UI in Maya with QT through Python.
When I use:
from Qt import QtCore
In the script editor, it throws the following error:
Error: ImportError: file line 2: No module named Qt #
I am just starting out to explore this subject. Does this mean Qt isn't installed ? Is it not a part of the default package of Maya 2018 and 2019 ?
Any pointers as to why this may happen will be really helpful.

Related

Qt 6.4.1, no Qt6Multimedia folder present - CMakeLists.txt can't find the module

I am using Qt 6.4.1, and in QtCreator I am trying to import the Qt6 Multimedia module, but I get the following error:
The error says "Found package configuration file: C:/Qt/qt/6.4.1/mingw_64/lib/cmake/Qt6/Qt6Config.cmake but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT FOUND. Reason given by package: Failed to find required Qt component "Multimedia". Expected config file at "C:/Qt/qt/6.4.1/mingw_64/lib/cmake/Qt6Multimedia/Qt6MultimediaConfig.cmake" does NOT exist"
It appears my Qt version does not have the folder in my cmake directory:
Why is this? Have I missed something/got something wrong or is there no support for the Multimedia module in Qt6.4.1? What can I do to import this module? Thanks in advance.
You need to check QtMultimedia in QtMaintenanceTool when you are installing Qt. See the screenshot:
If it is not available for your compiler, then you have no other option than build Qt with QtMultimedia on your own.

Error loading apt-installed QtDataVisualization at runtime on ubuntu

I'm running Qt 5.12 on ubuntu 20.04.3. Qt software components are installed with apt. My C++ application uses Qt DataVisualization . I've installed these apt packages for DataVisualization:
libqt5datavisualization5-dev
qml-module-qtdatavisualization
The app compiles OK, but the runtime cannot find the qml module. My qml file contains this import statement as specified by Qt documentation:
import QtDataVisualization 1.15
But at runtime I get the error:
QQmlApplicationEngine failed to load component
qrc:/main.qml:6 module "QtDataVisualization" version 1.15 is not installed
I get a similar runtime error if qml has "import QtDataVisualization 1.14".
Can someone help please? Thanks!
This page indicates that DataVisualization 1.2 should be imported for Qt 5.12 applications - this resolves my issue.

How to build shared libraries of qwt - how to prevent qmake from linking to QtCore and QtGui

I have the source code of qwt and while making shared libraries of qwt , I want to prevent qmake from linking to QtCore and QtGui
Looking forward to guidance
You can't. qwt uses Qt, so there's no way to build it as a shared library without linking it to QtCore/QtGui. To import Qt's symbols, it has to be linked to QtCore/QtGui import libraries - that's how qmake sets it up. Otherwise, the linker would have to emit a qwt library with a whole bunch of unresolved symbols, and it simply wouldn't work - it'd crash on the first reference to a Qt symbol, given that said symbol would have an address of zero.
To build it without linking it to Qt it has to be built as a static library. It will be then linked to Qt when the executable is linked.

Compiling in Qt Creator on OS X: "dyld: Library not loaded"

I've searched around and can't find an answer to this. I'm trying to compile some examples in Qt Creator (Qt 5.0.1) on Mac OS X Lion, and it keeps giving me errors. Here's the full error:
dyld: Library not loaded: /Users/bld.qt/bamboo-agent-home/xml-data/build-dir/DQTC-RELEASE5LGPL-OSX106/______________________________PADDING______________________________/lib/QtWidgets.framework/Versions/5/QtWidgets
Referenced from: /Users/<bleh>/Qt5.0.1/5.0.1/clang_64/examples/widgets/widgets/codeeditor-build-Desktop_Qt_5_0_1_clang_64bit-Debug/codeeditor.app/Contents/MacOS/codeeditor
Reason: image not found
Anyone know any fixes?
Thanks
Looks like it can't find the QtWidgets library. Add this to your .pro file
qt += widgets
Based on the transition from Qt 4 to 5 where QtWidgets are a Separate Module

Building Qt 4.8 with mingw fails - "I couldn't find a pro file for QtCore module"

I'm trying to re-build Qt 4.8.0 in Windows statically. I'm following the documentation here: http://doc.qt.nokia.com/4.8-snapshot/deployment-windows.html. After typing config -static in a mingw terminal at C:\QtSDK\Desktop\Qt\4.8.0\mingw, I get the following error:
Running syncqt...
I couldn't find a pro file for QtCore module
syncqt failed, return code 2
I've been looking all over and can't figure out where to go from here! IMO the Qt documentation is not very good in this regard.
Thanks!
Marlon

Resources