Adverti horiz upsell
Using QT Designer for MEL Interfaces
Using QT Designer for MEL Interfaces
css_maya, added 2010-05-04 13:15:19 UTC 87,643 views  Rating:
(7 ratings)
Page 3 of 3

OK, we made our UI and now we need to import it in Maya. Open the script editor and right the code below :

string $d=`internalVar -usd`;

string $dialog = `loadUI -uiFile ($d+"/test.ui")`;

showWindow $dialog;

 

Now select the code and hit CTRL+Enter to execute it. congratullation, your interface will be opened. But wait a minute, we still can see the spin box and that's not good. We don't need it. Now how can we hide it in QT? The answer is simple, select it in QT designer and in property editor change the hight and wide to 1 ! This way we hide it from others in view port. The picture below shows the same UI in Maya with a little change in place for some elements. As you can see, changing the dial and horizontal slider changes the text of the line edit control. Now you can use textField command and refer to these controls to query the text and put it in integer values. What if you need float values when sliding the slider? The answer is simple, you can change the command in -dc. Change the min and max value to 0 and 100 and add /100 after #1. Now openning UI in Maya and dragging horizontal slider, you can see that the text box will show you float number between 0 and 1 ! (I didn't do this step in picture below but I hide the spin box, the one you see is the double spin box that do nothing until you connect it to something.)

016

Now what if I want to make my UI dockable? Add the code below after your current code in script editor.

 

string $layout1=`paneLayout -cn "single" -p $gMainWindow`;

dockControl -aa "all" -a "right" -fl off -con $layout1 -l "MainWindow";

control -e -p $layout1 $dialog;

 

Now select your code and hit CNTL+Enter to execute it. Congratullation. Now you have a dockable UI that works in Maya. Now you can go and add your own controls and make your progress in Maya. If you had any question ask me by email to ali <at> cgfx3d <dot> com.

 

Have fun.