Qt C++ plugin crashes Maya

Qt C++ plugin crashes Maya

IUGeek
Explorer Explorer
942 Views
2 Replies
Message 1 of 3

Qt C++ plugin crashes Maya

IUGeek
Explorer
Explorer

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!

0 Likes
943 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Hi,

 

Not sure how much this will help, but I use Visual Stuido to generate the .mll file. I find the .pro file cumbersome and visual studio will auto build it for you. you can download the community version of visual studio and try it out.  I used this example for windows blog.josephkider.com/2015/08/20/creating-your-first-maya-plug-in-in-visual-studio/ If you know how to set up environment variable or its equivalent in Mac os, then you should be able to follow this to make it.

Here is the link for community version https://www.visualstudio.com/vs/community/

I have not tested this on Mac.

Hope it helps. Good Luck!

0 Likes
Message 3 of 3

IUGeek
Explorer
Explorer

Thanks for the reply.  

 

Unfortunately, Visual Studio is not available for the Mac, to my knowledge.  Also, I'm using Qt because that's what Maya uses under the hood for its own UI.  I still might take a look at the blog, though, just to see if the environment variable is something new.

 

Thanks!

0 Likes