-1

Is there any way to load qt compiled c++ code in maya?

//example code

void MainWindow::on_pushButton_clicked()
{
    ui->labell->setText("Hello");

}

actually i was created basic ui with text and push button, what i want is text should change to hello when i push button and i achieved that. so this connections were made with above code, after compiling this all works fine but when i load ui file in maya and i pushes the button text doesn't changes because actually code was written in c++. so, is there any alternative to load that code too along with ui file?

thank you,
Anvesh Chary
Anvesh Chary
  • 65
  • 1
  • 11
  • 1
    Your post doesn't suit your title. – Shannon Hochkins May 02 '14 at 06:06
  • if you are familiar with maya 3d software then you will understand what i am talking!!!! – Anvesh Chary May 02 '14 at 20:25
  • I am very familiar with maya, your question is totally different to your post. – Shannon Hochkins May 04 '14 at 22:48
  • You're asking how to load a UI file in Maya, yes your post is setting the text of a label... – Shannon Hochkins May 04 '14 at 22:49
  • sorry for that actually my question is "Is there any way to load qt compiled UI file in maya?" but i can not post my question with this so i added this line in header subject.... this code only working in qt but not in maya, window launching successfully but text doesn't change into "hello" because this connection is created through code. so am asking that is there any way to load ui with this connection.... hope i understood.... – Anvesh Chary May 05 '14 at 08:12

1 Answers1

0

To load a .ui file in Maya, I've previously done this in python, I'm not sure about C++ but I don't believe maya interprets C++ directly anyway (I could be wrong there).

import maya.cmds as cmds

ve = cmds.about(version=True) 
conv = "%s"%ve 
versionOutput = float(conv[0:4])
def mayaVers():
    cmds.warning("You're using Maya %s! You need to be using Maya 2011 or greater to be compatible with this script.\n" % conv);
def loadUIWindow():
    if versionOutput >= 2011:
        if (cmds.dockControl('dockUIWindow', exists=True)):
            cmds.deleteUI('dockUIWindow')
        scriptsDirectory = cmds.internalVar(usd=True)        
        UIWindow = cmds.loadUI(uiFile=scriptsDirectory + "/uifilename.ui")
        dockSoftMod = cmds.dockControl('dockUIWindow',area="left", content='uiwindowname', label="")
    else:
        mayaVers()
loadUIWindow()

Here's how I've done it in the past, if you're just looking to source a UI file into the Maya session, this is how it can be done.

Obviously you'll need to either put your ui file in the scripts directory, or change the uiFilePath to your file.

Also, the content flag in the dockControl is important, this needs to be the name of the window or control that you're trying to dock. Let's say you have called your UI file wrapper 'win', the content flag would need to be the same.

EDIT

After you load the UI file, you can edit any element in the window if you know it's name.

cmds.button('ParentBtn', edit=1, command="parentObject()")

Hope this helps.

Shannon Hochkins
  • 11,763
  • 15
  • 62
  • 95
  • you are not getting me.... i can load ui file in maya with simple 2 lines of mel code but text does not changes into "hello" which i was specified when button was pushed and i tried your python code it is loading window and docked to left but text does not changes when button was pushed.... am i getting you? – Anvesh Chary May 06 '14 at 05:14
  • You've stated twice now that your question is `Is there any way to load qt compiled UI file in maya?`. To me, that sounds like you're after how to load the UI file. If you're just trying to edit a label or button etc, have a look at my revised answer. – Shannon Hochkins May 06 '14 at 05:39
  • my procedure is in c++ not in python.... is there any alternative to load my c++ procedure? – Anvesh Chary May 06 '14 at 08:05
  • Pymel, Python etc, take advantage of the api to interpret C++ commands through python, Maya doesn't let you read/write directly in C++, you'd have to compile it into a plugin, say `.mll` etc. – Shannon Hochkins May 06 '14 at 22:00