Using QT Designer for MEL Interfaces

Using QT Designer for MEL Interfaces

css_maya, added over 16 years ago 87,764 views Rating:
(7 ratings)
Page 2 of 3

As I mentioned in previous page we need to connect some of the controls to others for having access by MEL. For this, you need to connect them by hand. QT is not like MEL. in MEL you can assign a string text from one control to an integer variable as long as that text contains just numbers but, in QT it's not possible.
Now hit "F4" to go to "edit signals/Slots" mode (or you can choose it under edit menu). In this mode you can't move controllers around but you can connect them with each other with similar attributes. Now select the spin box and drag it to line edit. As you can see a red line will appear with an arrow at the end. In picture below I dragged dial control to spin box (if you want to use dial control you can't connect it to double spin box because double spin box will receive just double values and dial will send integers so you need to connect it to spin box.)
006
Now a new window will pop up. Pay attension that i checked "show signals and slots inherited from QWidget". Keep this setting on because some of the attributes will be hidden by normal settings (like setVisible).
007
The left hand list is your driver list and the right hand one is your driven. Now select valueChanged(int) from left list and setValue(int) from right side and hit OK. Now drag spin box over line edit and select valueChanged(QString) from left and setText(Qstring) from right. As you see spin box can output bot QString and int values (the attribute below in list) so if you want to connect a spin box to a slider you should choose the one that has int in it's name. Now hit OK. Now hit "F3" to go back to design mode.
The next thing we need to do is to give our push button and horizontal slider action in Maya. Select push button and in property editor (right side bar of QT designer) hit the plus button and select string from menu. In the opened window type -c (as you remember it's a flag for button command of maya, you can add as many flags as you need like this.)
008
009
Now you have a dynamic attribute and you can type anything in it. Now qnother line edit at left side of the slider. in property editor change the objectName to slider_view. Change it's enabled attribute and uncheck it. Now select the horizontal slider and add a dynamic attribute. Type -dc (for dragCommand flag of inSlider). Now move down the list to see your attribute and type "textField -e -tx #1 slider_view" (with " marks!). the #1 in this command will return the value of the same controller (slider in this case).
Now save the project from file menu in your script folder of maya as test.ui . In next page we will import this UI in Maya.

Comments

  • John Neumann · 2010-07-12
    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 · 2010-08-14
    UPS thanks man
  • yanez · 2010-08-25
    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 · 2010-08-28
    >> 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 · 2011-01-05
    How to parent two windows on one layout
  • css_maya · 2011-01-05
    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 · 2011-01-16
    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 · 2011-01-16
    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 · 2011-02-22
    good
  • pblnrao3d · 2011-03-10
    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 · 2011-03-13
    @pblnrao3d - Unless you're using PyQt as a wrapper and writing it in Python you can't.
  • pblnrao3d · 2011-03-14
    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
  • attackack · 2011-06-06
    Thanks for this tutorial , it has been extremely helpful and made my task very easy! cheers!
  • k j · 2011-08-28
    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 · 2012-08-06
    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 · 2014-12-20
    Hey CSS, Do you know how to utilize Python Commands with QT? Many thanks, Criso
Sign in