QML in Houdini ?

   2216   0   1
User Avatar
Member
34 posts
Joined: July 2006
Offline
Hi,

Does anyone have an idea how to run QML with PySide2 inside Houdini?

I tried these simple examples and it seems that they don't work.

from hou.session:

from PySide2.QtWidgets import *
from PySide2.QtQuick import QQuickView
from PySide2.QtCore import QUrl, Qt

class MyWidget(QWidget):
    def __init__(self, *args, **kwargs):
        super(MyWidget,self).__init__(*args, **kwargs)
        view = QQuickView()        
        url = QUrl("view.qml")
        view.setSource(url)        
        self.createWindowContainer(view)        
        self.setParent(hou.ui.mainQtWindow(), Qt.Window)

def show():
    foo = MyWidget()
    foo.show()

QML: view.qml

import QtQuick 2.6

Rectangle {
    id: page
    width: 640
    height: 480
    color: "lightgray"

    Text {
        id: helloText
        text: "Hello world!"
        y: 30
        anchors.horizontalCenter: page.horizontalCenter
        anchors.verticalCenter: page.verticalCenter
        font.pointSize: 24; font.bold: true
    }
}

from python panel:

from PySide2.QtWidgets import QWidget
from PySide2.QtQuick import QQuickView
from PySide2.QtCore import QUrl


def onCreateInterface():
    view = QQuickView()
    url = QUrl("view.qml")    

    view.setSource(url)
    widget = QWidget.createWindowContainer(view)
    return widget

Any ideas ?Should I use QtQml.QQmlApplicationEngine somehow ?
https://vimeo.com/timmarinov [vimeo.com]
  • Quick Links