Thursday, February 4, 2010

Developing custom Qt UI widgets for Maya 2011: A first look


This has been solved!!!

Check out my newer post here


Now that I’ve been using the new look Maya I kinda like it. The Maya UI always seemed cold and impersonal compared to Max which now for me is like a third brain lobe. I’ve also been looking for an excuse to learn Qt and Maya 2011 fits the bill.

For those who don’t know Qt is a cross platform system mainly used for the front end of applications but has other libraries such as database and web access. When Nokia bought Qt it sent good vibes out into the industry. Basically everyone now knows a large corporation is investing in this thing so it must be good. It’s also good to know someone is there to support the community and drive innovation in Qt. The CG industries have especially taken liking to Qt because it’s UIs look and perform very well, have GL integration and are consistent between platforms. These are things that help sell a product to end user artists.

Here’s a link to some hype, but this time you can probably believe it:

http://qt.nokia.com/qt-in-use/qt-in-visual-effects

And now Qt’s use in Maya has sealed the deal as an early industry standard.

Now for the disclaimer: I’m currently learning Qt and relearning Maya development so please take anything I say here with a pinch of salt.

Here are some early finding:

You need to be developing with the same Qt version as the app you are developing plugins for (I’m talking Qt system plugins here not Maya SDK plugins).

So I found a MEL command that returns the Qt version used by Maya:




Now as of time of writing the latest Qt version is 4.6.1. The latest release of the full Qt SDK package using 4.5.3 framework is 2009.04 , which can be found here (Windows):

http://get.qt.nokia.com/qtsdk/qt-sdk-win-opensource-2009.04.exe

To be clear, a UI element in Qt is called a Widget.

Qt has it’s own nifty plugin system for all sorts of stuff which has standard plugin folder names. From trawling the Qt help and Maya 2011 folders I found these:

From the Qt help

Locating Plugins

Qt applications automatically know which plugins are available, because plugins are stored in the standard plugin subdirectories. Because of this applications don't require any code to find and load plugins, since Qt handles them automatically.

And it just so happens that we have such a folder here:

C:\Program Files (x86)\Autodesk\Maya2011\qt-plugins

Now Qt plugins need to be in strictly named subfolders.

From the Qt help



Base Class
Directory Name
Key Case Sensitivity
accessiblebridge
Case Sensitive
accessible
Case Sensitive
decorations
Case Insensitive
fontengines
Case Insensitive
iconengines
Case Insensitive
imageformats
Case Sensitive
inputmethods
Case Sensitive
kbddrivers
Case Insensitive
mousedrivers
Case Insensitive
gfxdrivers
Case Insensitive
script
Case Sensitive
sqldrivers
Case Sensitive
styles
Case Insensitive
codecs
Case Sensitive


But there is no mention of Widgets here you might ask, so did I. So from reading some help and looking in the Qt install folder I found that you need to put Widget plugins in a designer folder. Ie

C:\Program Files (x86)\Autodesk\Maya2011\qt-plugins\designer\myWidgetPluginProbablyGoesHere.DLL

If you’re looking for examples of custom Widgets look in the Qt Designer or just Designer sections. I’m using the World Time Clock Plugin example till I make my own widget.

Now I booted by Qt Creator 2009.4 using framework 4.5.3 and compiled the World Clock project which produces a file called worldtimeclockplugin.dll. So I copied it here:

C:\Program Files (x86)\Autodesk\Maya2011\qt-plugins\designer\worldtimeclockplugin.dll and then loaded the UI file in the same project using Python:




This code created a window with the other standard widgets but the clock widget was not there. One of my main asumtions about this was that Maya would actually load my DLL so I booted up Process Monitor and checked what was going on when I ran the Python code. Sure enough Maya was accessing my DLL where I put it but it was also looking for it here:

C:\Program Files (x86)\Autodesk\Maya2011\bin\designer

I can remember reading somewhere in the Qt help that it will look for the standard plugin folders in the execution path so fair enough, I put the DLL there as well.

Still no widget. Maya is not generating any errors and according to Process Monitor all the DLLs it’s looking for are being found.

And that’s where I’m up to. Not much to go on except stuffing around with versions etc and looking at the Qt help. Hopefully I’ll have some actual results soon.

3 comments:

  1. I can't contact you by email so...
    Can you send me an email? I would like to ask you some questions.
    mine is homeless3d at gmail _com.
    Thank you very much.

    ReplyDelete
  2. Please post some screenshots of maya 2011! I'd really like to see what they have done with the interface

    ReplyDelete
  3. screenshots of maya 2011 - http://www.toxik.sk/?p=67

    ReplyDelete