Adverti horiz upsell

Top Marketplace

All 3D Models Scripts Rigs Shaders

Top Free Downloads

All Scripts Rigs Shaders Apps

Using QT Designer for MEL Interfaces
Using QT Designer for MEL Interfaces
css_maya, added 2010-05-04 13:15:19 UTC 79,467 views  Rating:
(5 ratings)
Page 1 of 3

When for the first time I saw Maya 2011 and learned about QT I thought that it must be hard. Most of the time companies won't integrate other things in their programs sufficiantly. But, after a week of working with QT, I must say that god bless all those people in Autodesk.
Developing an interface in QT is simple and fast and it works like charm. You need to download QT and install it. After installation, you'll have a program called "Designer". Opening it will give you option to choose from diferent window templates.
001
Now we select "Main window" and hit "Create" button. A new blank window will appear. This window has a menu bar (on top) and status bar (on bottom). Most of the time you don't need these so you can right click and delete them but if you want to have menu bar then you can use it.
In the picture below I gathered almost all the awailable controls that will work with Maya (directly or indirectly).
005
1-push Button (under Buttons group) --------------------Maya command to access------------> button;
2-radio button (under Buttons group) --------------------Maya command to access------------> radioButton;
3-check box(under Buttons group) -----------------------Maya command to access------------> checkBox;
4-combo box (under containers group) ------------------Maya command to access------------> optionMenu;
5-line edit (under input widgets group) -------------------Maya command to access------------> textField;
6-spin box (under input widgets group) ------------------Maya command to access------------> NONE
7-double spine box (under input widgets group)---------Maya command to access------------> NONE
8-dial (under input widgets group) ------------------------Maya command to access------------> NONE
9-list view (under item views model based) --------------Maya command to access------------> textScrollList;
10-horizontal slider (under input widgets) ----------------Maya command to access------------> intSlider;
11-label (under display widgets group) -------------------Maya command to access------------> NONE
12-progress bar (under display widgets group) ----------Maya command to access------------> progressBar;
13-vertical slider (under input widgets) -------------------Maya command to access------------> intSlider;
14-horizontal line (under input widgets) ------------------Maya command to access------------> NONE
15-vertical line (under input widgets) ---------------------Maya command to access------------> NONE
16-group box (under containers group) ------------------Maya command to access------------> NONE
17-tab widget (under container group) -------------------Maya command to access------------> tabLayout
18-main window --------------------------------------------Maya command to access------------> window;

Now, as you can see, we have no command to access spin boxes or dial control so we need to redirect them to somthing else in the UI that is accessible with MEL.

Comments

  • Cadmium77

    Cadmium77 said over 6 years ago:

    Thanks a lot. This is awesome...Great write up. Oh and to those who want it; http://qt.nokia.com/qt-in-use/autodesk
  • John Neumann

    John Neumann said over 6 years ago:

    I'd like to point out that this is wrong: 9-list view (under item views model based) --------------Maya command to access------------> textScrollList; That view will NOT give you any feedback at all. However, if you use the List Widget (under Item Widgets Item-Based), you will be able to use that to populate a textScrollList. Hope this helps someone else.
  • css_maya

    css_maya said over 6 years ago:

    UPS thanks man
  • yanez

    yanez said over 6 years ago:

    Could i use this tutorial for modifying the main Maya GUI? I would add a bottom for Outliner, graph editor and Hypergraph, beside the three trasform fields in the status line. Thanks
  • Joojaa

    Joojaa said over 6 years ago:

    >> Yanez No, but adding a button to the outliner, grapheditor and hyopergraph is pretty trivial in even older mayas. All you need is to know the name of the gui item you want to inject stuff into and inject. Hees a fairly simplistic example, note im doing a bit of sloppy job attaching it because im not so much on time and i attach it to the right just before the show hide attribute editors because its easier (otherwise id have to change the command toggleInputField): $formName=("MayaWindow|mayaMainWindowForm|"+ "formLayout1|formLayout12|formLayout13|"+ "formLayout41|formLayout42"); setParent $formName; $button=`button -l demo -c OutlinerWindow`; formLayout -edit -attachForm $button "right" 5 $formName; You can make this considerably neater BUT, i suggest you do not make theese buttons make hotkeys instead, its better faster and doesnt slow down you usage experience as a small button would (yes they would because the statusline is so small in area)
  • dare daree

    dare daree said almost 6 years ago:

    How to parent two windows on one layout
  • css_maya

    css_maya said almost 6 years ago:

    dare daree, do you mean when you are designing in QT? or do you mean adding two different QT UI's to two different maya panels?
  • catman2010

    catman2010 said almost 6 years ago:

    Many thanks for the tutorial, it's a great help. I'm stuck on one thing though, I can't seem to get the float part working. I'm using this - "textField -e -tx (#1/100) sliderView" but the textField only displays zero for the range of the slider and switches to 1 at the end. How do I make it see the float values?
  • catman2010

    catman2010 said almost 6 years ago:

    I found a way that works, instead of doing the calculation in the -dc command on the slider I just added a global procedure called 'update' which takes the value from the slider and divides by 100, then feeds this into the text field. I'll post the MEL below in case it's handy for someone else. [CODE] //set the scripts directory so we can load our ui file string $scriptsDirectory = `internalVar -usd`; //load the ui file string $testWindow = `loadUI -uiFile ($scriptsDirectory+"/test.ui")`; //show the window showWindow $testWindow; // set up the initial value for the text field update; // procedure to update the text field as the slider changes - this is driven from the slider dragCommand global proc update(){ float $sliderVal = `intSlider -q -value horizontalSlider`; float $readOut = ($sliderVal/100); textField -e -text ($readOut) sliderView; } [/CODE]
  • valk

    valk said almost 6 years ago:

    good
  • pblnrao3d

    pblnrao3d said over 5 years ago:

    Great tut.... How to implement this in maya 2009 or below.....? and is there a script/ document to know the maya gui item, so that i can add some items as per the requirements.....
  • John Neumann

    John Neumann said over 5 years ago:

    @pblnrao3d - Unless you're using PyQt as a wrapper and writing it in Python you can't.
  • pblnrao3d

    pblnrao3d said over 5 years ago:

    Thx john for ur response.... As per my understandings, correct me if i am wrong. I think PyQt is s CUI based. So there is no other way to create a GUI in any other tool/application (i mean creating GUI by Drag & Drop like Qt Designer). Only way is to we need to code it. And you did not say abt way.... how to find the maya global variables like...... Maya Object/Item - In MEL - In Python -------------------------- ------------ --------------- Maya Main MenuBar - $MainWindow - MayaWindow
  • ravi singh

    ravi singh said over 5 years ago:

    Hi, I am stuck. Ok This is what I am trying to do. Very simple. I have a slider and a button made in QT designer. What I want is when I press the button, I want to create a sphere in Maya using MEL for the radius equal to the slider value. So I went ahead and added a dynamic property to the button -command "sphere -ch on -o on -po 0 -ax 0 1 0 -r #1 radiusHSlider -s 22 -nsp 22" The window loads properly in Maya (using "loadUI -uiFile"). When I select the button, I get an error "// Error: No object matches name: radiusHSlider // "radiusHSlider" is the object name of the slider in QT designer. Why maya cannot find its name. Please advise. Thanks ravi
  • attackack

    attackack said over 5 years ago:

    Thanks for this tutorial , it has been extremely helpful and made my task very easy! cheers!
  • ravi singh

    ravi singh said over 5 years ago:

    Checkout the tutorial "Introduction to Maya UI in QT and Python" at http://ivoxelstudios.com/blog/?p=51
  • k j

    k j said over 5 years ago:

    Hi, I have a problem with tabLayout/ tab widget. I created tab widget in QT Creator and name it for example “tabContainer”. After that, I tried to have a access to it form mel, and I couldn’t. The command “tabLayout -ex tabContainer;” gave mi 0. It works for button and some other stuffs. Does the tabLayout / tab widget will return any feedbuck?
  • koki nozawa

    koki nozawa said over 4 years ago:

    Hi, tried to use the label widget to add a image into my gui, but when i load the ui file in maya it doesnt show. is there any solution for this?
  • crisosphinx

    crisosphinx said almost 2 years ago:

    Hey CSS, Do you know how to utilize Python Commands with QT? Many thanks, Criso

Please sign up or sign in to post a comment.