QT Designer Signal Editor, QUiLoader()

490 views
Skip to first unread message

Macbeth R.

unread,
Mar 10, 2017, 9:21:49 AM3/10/17
to Python Programming for Autodesk Maya
Hi all, I try to migrate some stuff I had been doing from PyQt in Maya2015 to PySide2 in Maya2017.

So first trouble for me is the way the .UI files are being loaded.  I saw an example in devkit folder "devkit\pythonScripts\createNodeUI.py" and it actually works.

But I am used to create most of my non dynamic signals inside Signal Editor in QT Designer, and the way the UI is loaded in the example, doesn't allow the connections to be made from qt designer, I try to load the UI directly to self, instead of self.ui but it doesn't even gives any error.

Any help is appreciated!! thanks!

This is example I only created a button in Qt designer with a connection to myFunc()

# Copyright 2015 Autodesk, Inc. All rights reserved.
# Use of this software is subject to the terms of the Autodesk
# license agreement provided at the time of installation or download,
# or which otherwise accompanies this software in either electronic
# or hard copy form.

from maya import cmds
from maya import mel
from maya import OpenMayaUI as omui 

try:
  from PySide2.QtCore import * 
  from PySide2.QtGui import * 
  from PySide2.QtWidgets import *
  from PySide2.QtUiTools import *
  from shiboken2 import wrapInstance 
except ImportError:
  from PySide.QtCore import * 
  from PySide.QtGui import * 
  from PySide.QtUiTools import *
  from shiboken import wrapInstance 


import os.path


mayaMainWindowPtr = omui.MQtUtil.mainWindow() 
mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QWidget) 

class CreateNodeUI(QWidget):
    def __init__(self, *args, **kwargs):
        super(CreateNodeUI,self).__init__(*args, **kwargs)
        self.setParent(mayaMainWindow)
        self.setWindowFlags( Qt.Window )
        self.initUI()
        
    def initUI(self):
        loader = QUiLoader()
        file = QFile("C:\\test2.ui")
        file.open(QFile.ReadOnly)
        self.ui = loader.load(file, parentWidget=self)
        file.close()


    def myFunc(self):
        print "Clicked Button"



def main():
    ui = CreateNodeUI()
    ui.show()
    return ui


if __name__ == '__main__':
    main()

Marcus Ottosson

unread,
Mar 10, 2017, 10:18:18 AM3/10/17
to python_in...@googlegroups.com

Hi Macbeth,

Have a look here.

In short, you can build cross-compatible QtDesigner files if you take special precautions.

Hope it helps.

Best,
Marcus


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7ad88c15-1c4f-4781-97d9-1bb2977bbd09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages