Qt C++ plugin crashes Maya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Okay, so I'm learning how to create a C++ plugin for Maya on Mac OSX 10.10.5. At the moment, I'm working with Maya 2016, because that's what I have, but I'll be moving forward to newer versions once I get started.
I'm using Qt Creator for my development environment, because I want to create a Qt interface. I can get it to compile just fine without any references to any Qt libraries or headers, but as soon as I include anything Qt, the plugin causes Maya to crash. Running Maya from the command line, I get a stack trace when it crashes. I also get a few warnings that may or may not be part of the problem. Here are those warnings:
objc[10383]: Class QNSApplication is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /Library/Frameworks/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
. . . which is repeated for a number of classes - 20 or so. Then, when I try to open a script editor window, Maya crashes with a stack trace and the message "Must construct a QApplication before a QPaintDevice". I don't have a .ui file or classes for it defined yet. I also don't have any Qt objects referenced anywhere in my code yet. If I take the Qt libraries out of the project altogether, the plugin compiles and runs just fine. However, that sort of defeats the purpose of using Qt.
I'm not sure what's going on. The plugin itself is dirt-simple - nothing more than a "hello world" to get started. I also grabbed the helixQtCmd sample and tried that, with the same results, so I'm convinced it's part of my toolchain that's doing it. Here's what my .pro looks like:
include(qtconfig) TARGET = MayaTest HEADERS += mayatest.h SOURCES += mayatest.cpp macx: LIBS += -lOpenMayaUI CONFIG -= -dynamiclib macx: QMAKE_LFLAGS_PLUGIN -= -dynamiclib macx: LIBS -= -dynamiclib macx: LIBS += -L$$PWD/../../../../../Applications/Autodesk/maya2016/Maya.app/Contents/MacOS -lOpenMaya -lFoundation macx: INCLUDEPATH += $$PWD/../../../../../Applications/Autodesk/maya2016/include/qt macx: INCLUDEPATH += $$PWD/../../../../../Applications/Autodesk/maya2016/include/qt/QtCore macx: INCLUDEPATH += $$PWD/../../../../../Applications/Autodesk/maya2016/include/qt/QtGui macx: INCLUDEPATH += $$PWD/../../../../../Applications/Autodesk/maya2016/include
The qtconfig file is the same one that ships with the helixQtCmd example, except I defined the MAYA_LOCATION variable. Everything else is stock.
Any guidance? Thanks!