Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PySide2 QQmlApplicationEngine No Window
Forum Updated to NodeBB v4.3 + New Features

PySide2 QQmlApplicationEngine No Window

Scheduled Pinned Locked Moved Unsolved Language Bindings
2 Posts 2 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ruchitinfushion
    wrote on last edited by ruchitinfushion
    #1

    Hi,
    I am trying to run below code inside Maya, it runs without any error but still engine window is not visible. Tell me what's wrong or missing in code ??

    ball. py

    from PySide2.QtCore import QObject, QUrl, Slot
    from PySide2.QtQml import QQmlApplicationEngine
    from PySide2.QtQuick import QQuickWindow
    import maya.cmds as mc
    
    class Ball(QObject):
        def __init__(self):
            QObject.__init__(self)
    
        @Slot(int) 
        def add(self, arg1):
            mc.polySphere(r=arg1)
            
    engine = QQmlApplicationEngine()
    ball = Ball()
    engine.rootContext().setContextProperty("ball", ball)
    engine.load("E:/code/ball.qml")
    

    ball.qml

    import QtQuick 2.3
    import QtQuick.Controls 1.2
    
    ApplicationWindow {
        id: itemID
        visible: true
        width:480
        height:320
        color: "whitesmoke"
    
        Slider {
            id: radiusSliderID
            x: 214
            y: 141
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
            stepSize: 1
            maximumValue: 20
            minimumValue: 1
            value: 1
        }
    
        Text {
            id: radiusValueID
            x: 218
            y: 194
            text: radiusSliderID.value
            font.bold: true
            anchors.horizontalCenter: parent.horizontalCenter
            font.pixelSize: 30
        }
    
        Button {
            id: sphereBtnID
            x: 208
            y: 262
            width: 80
            height: 30
            text: qsTr("Create Sphere")
            anchors.horizontalCenter: parent.horizontalCenter
            onClicked: {
                ball.add(radiusSliderID.value)
            }
        }
    
    }
    
    
    1 Reply Last reply
    0
    • P Offline
      P Offline
      Petri
      wrote on last edited by Petri
      #2

      Have you doublechecked how things should be run inside Maya?

      I suggest you try running the code as a standalone Python QT app first. For that, your code will need to also instantiate a QApplication object and then run the _exec method on it. That may actually be the reason why you're seeing nothing...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved