22 comments

  • Any luck getting this approach to run in a class?

  • Any chance to add QWidget to maya layout. I’m trying to add maya frame layout to Qt UI and QWidgets to that frame layout.

    • Hi! I don’t understand your question. You first say “add QWidget -> maya layout” and then you say ” add maya layout to Qt” again. You mean, adding a QWidget to a maya item?

      • Yes, I mean QWidget to maya item!
        Thank you

        • That’s a good point. I never really tried it. That’s good for another article! In the meantime I suggest you visit StackOverflow or a similar forum where you can get an answer faster! I’m quite busy these days. Cheers

        • Vaishak Purushothaman

          you can set objectName on Qt Widget and parent it to a maya layout. Try this minimal example,

          import maya.cmds as mc
          import maya.OpenMayaUI as omui
          from PySide2.QtWidgets import QListWidget

          qt_widget = QListWidget()
          qt_widget.setObjectName(“QT_ListWidget”)
          qt_widget.addItems(“Qt in maya is interesting”.split(” “))

          win = mc.window()
          col_lay = mc.columnLayout(adj=1)
          mc.control(“QT_ListWidget”, e=1, p=col_lay)
          mc.showWindow(win)

  • Hey there! this might look silly, but i’m just starting at this coding thing! 🙂 how can i make this window to be the Graph Editor?

    • Hi ! It’s a pretty good question, of course. It’s not silly ^_^.

      I had never done this, but opening the GraphEditor I activated “Show All Commands” in the script editor to see what’s going on in the backstage… (Be sure to turn Echo All Commands off again after this, or will make Maya terribly slow).

      After that, I found out a couple of commands that are run when creating the GraphEditor.

      outlinerEditor and animCurveEditor

      So you should create both reading the documentation for those commands in the Maya Help.

      You need to change this line:
      modelPanelName = modelPanel("embeddedModelPanel#", cam='persp')

      for this one:
      modelPanelName = cmds.animCurveEditor("embeddedGraphEditor#", the rest of parameters here... if any)

      But as you can see, this will just create the lower part of the editor. (The timeline). To get both parts you should create a Vertical Layout in Qt that contains the animCurveEditor this way and then repeat the whole process of adding another PaneLayout for the outlinerEditor.

  • Hey Lidia

    Thanks for this helpful post! I’m using some of the code you have above in a tool I’m creating for a camera rig, but have run into an issue when giving the layout an arbitrary name.

    Here’s my code: https://pastebin.com/vZcjxXiq

    The implementation of your script begins after line 81.

    The error I receive is: “line 88: setParent: Object ‘viewportLayout’ not found. # ”

    I’m guessing this has to do with how I’m importing PySide2, but I need that flexibility since our studio is back and forth between Maya 2016 & Maya 2017+.

    Any ideas on how to fix this?

    • About PySide and PySide2, use the very famous qt.py used but major vfx studios. https://pypi.python.org/pypi/Qt.py I suggest you visit the homepage.

      I can see in your code you do this:

      qtViewportLayout.setObjectName (“viewportLayout”)

      I suggest you check there’s nothing else called like this. Try to run getObjectName afterwards. I suggest you store that in a variable and use it, instead of using directly the name. The other option is to create a unique name by adding a timestamp number after that string, so that it’s never the same.

      cmds.setParent (“viewportLayout1283482439234”)

  • Thanks for the post. One thing that I have noticed is that the none of the commands on the modelEditorIconBar works. (i.e. if I click on the shaded icon, the viewport does nothing.) Is there a way to fix this issue?

    Thanks

  • Any luck getting pyside2 to launch a ui in maya macos without crashing maya?

  • late to the party, thanks so much for this Lidia!

  • I’ve been searching far and wide to look for solutions for broken scripts that were written for pre-Maya 2017 at my studio, and this post was the only one that led me to a fix!

    Thank you so much for taking time to write this post, Lidia.

Leave a Reply

Your email address will not be published. Required fields are marked *