Oct 2013
1 / 3
Oct 2013
Dec 2013

I can get Qt working on its own with visual studio 2010, but when i use my qt libraries a plugin for maya, it doesnt load the plugin.

in the maya docs it says use the libraries in their filders but when i unzipped them i wasn't able to link against any of them and the docs went no further about what to do.

anyone able to tell me how i get qt working with maya in c++, im trying to compile the helixQtCmd examples in the maya 2014 docs

cheers 

  • created

    Oct '13
  • last reply

    Dec '13
  • 2

    replies

  • 2.4k

    views

  • 1

    user

1 month later

I'm working on Maya 2013, but it's fairly easy...

To be able to compile and link Qt content, you just need:

  • to unzip the Qt-includes (see C:\Program Files\Autodesk\Maya\include\Qt)

  • download the modified Qt source from Autodesk and follow instructions within
    ... if you really did that, it should already be it ...

  • set include-dirs correctly in your project

  • set lib-dirs correctly in your project

  • and - MOST IMPORTANT: do not use includes like "#include " - use "#include " instead!

  • you also need the Qt SDK to be able to run moc, uic and qrc (that was told to you in the docs of the modified Qt source)

  • an idea of where and when to run moc, uic and qrc (and maybe other qt tools): for each of those files you'll have to set up a special build-rule in your project - f.e. I made a QPushButton-Derivative -> the class' header contains the Q_OBJECT macro - so it needs to run moc before compiling the actual c++ code: solution-explorer, right-click the header, select Properties
  • General->Item Type = Custom Build Tool
  • Custom Build Tool->CommandLine = C:\qt\2010.05\bin\moc.exe  -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\Program Files\Autodesk\Maya2013\include\Qt\QtCore" -I"c:\Program Files\Autodesk\Maya2013\include\Qt\QtGui" -I"c:\Program Files\Autodesk\Maya2013\include\Qt" -Ic:\qt-adsk-4.7.1\mkspecs\win32-msvc2010 -D_MSC_VER=1600 -DWIN32 %(FullPath) -o $(ProjectDir)$(Platform)\moc_%(Filename).cpp
  • Obviously I have built my modified Qt source - and I'm using it ...
  • Btw. the release-libs can be found at C:\Program Files\Autodesk\Maya\lib - you can also link debug-builds against the release-libs, you just won't have good chances for debugging, then.

    P.S.: as soon as you unpacked the includes and added include- and lib-dirs to your project (and obviously lib-dependencies - i.e. "link against QtCore4.lib"), you could f.e. use QString (as MString is just simply a crap-class) in your code.  Just for using Signals & Slots or deriving classes from Qt you'll need the moc and by that the Qt sources built.

    Another P.S.: maybe you don't get that Visual Studio command prompt working?

    I created a Powershell profile to start PS with a Visual Studio Command Prompt x64:

    $env:QTDIR='c:\qt\4.7.1'
    $env:PATH="$env:QTDIR;$env:PATH"
    $env:QMAKESPEC="win32-msvc2010"
     
    $tempFile = [IO.Path]::GetTempFileName()
    $script = 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat'
    cmd /c “ `"$script`" && set > $tempFile ”
    Get-Content $tempFile | Foreach-Object {  
        if($_ -match “^(.*?)=(.*)$”) 
        {
            Set-Content “env:\$($matches[1])” $matches[2] 
        }
    } 
    Remove-Item $tempFile 
    Remove-Variable tempFile; Remove-Variable script
     
    (gci env: | where {$_.Name -match ".+include"}).Value | foreach { 
        $env:INCLUDE += ";$_";
    }
    (gci env: | where {$_.Name -match ".+lib"}).Value | foreach {
        $env:LIB += ";$_";
    }

    Then I created a simple "create vcproj from qt .pro" script:

    param(
    [parameter(Mandatory=$true,Position=1)][string] $filepath
    )
    $global:fp = Get-ChildItem $filepath
    Set-Location $fp.DirectoryName
    qmake -tp vc -r ($fp.Name)