Display QQmlApplicationEngine

90 views
Skip to first unread message

Ruchit Bhatt

unread,
Jul 30, 2018, 12:57:15 PM7/30/18
to Python Programming for Autodesk Maya
How to run & display QQmlApplicationEngine in Maya using PySide2?
Here is my code

class Ball(QObject):
   
def __init__(self):
       
QObject.__init__(self)

   
@Slot(int)
   
def add(arg1):
        mc
.polySphere(r=arg1)
       
       
engine
= QQmlApplicationEngine()
ball
= Ball()
engine
.rootContext().setContextProperty("ball", ball)
engine
.load(QUrl.fromLocalFile("E:/code/QML/sphere.qml"))


Justin Israel

unread,
Jul 30, 2018, 3:29:25 PM7/30/18
to python_in...@googlegroups.com
Is it giving you an error? You do have a bug in your Ball.add(). It should be 

@Slot(int)
def add(self, arg1):
    mc.polySphere(r=arg1)



--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d1a58266-9ab4-4ce9-ad4e-463a8e850d5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruchit Bhatt

unread,
Jul 30, 2018, 4:22:38 PM7/30/18
to Python Programming for Autodesk Maya
I did few test with QQMLAPPLICATIONENGINE outside Maya & everything works fine. Problem with Maya is, If I use
app = QApplication(sys.argv)

Maya give a error
# Error: RuntimeError: A QApplication instance already exists. #

I have no idea how to show QQmlApplicationEngine window in Maya..Many people use QQuickView.show() but I found QQmlApplicationEngine is more powerful than QQuickView.

Justin Israel

unread,
Jul 30, 2018, 4:35:46 PM7/30/18
to python_in...@googlegroups.com
Maya already has a QApplication instance running. So I would think you just create the engine and load your file. 


--
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_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages