Getting started with QML

Pyblish is built on a heavy dose of QML.

A 4-part series on it was just made available through ICS and I thought I’d spread the love.

Best Practices in Qt Quick/QML

  • Part 1 - Building blocks of QML
  • Part 2 - Creating New Items
  • Part 3 - Reuse and QML modules
  • Part 4 - Dynamic Item Creation

It requires sign-up, but I think it’s worthwhile.

Getting Started

Here’s something to get you started with the PyQt5 distribution shipping with Pyblish on Windows.

(1). Save these two files.

main.qml

import QtQuick 2.4

Rectangle {
    width: 800
    height: 600
    color: "steelblue"
}

main.py

import os
import sys
from PyQt5 import QtQuick, QtCore, QtGui

# Initiate run-time
app = QtGui.QGuiApplication(sys.argv)

# Locate main.qml
source = os.path.dirname(__file__)
source = QtCore.QUrl.fromLocalFile(os.path.join(source, "main.qml"))

# Load main.qml
window = QtQuick.QQuickView()
window.setSource(source)
window.show()

# Start
app.exec_()

(2). Run main.py using pyblish_win\bin\python.bat
(3). You will be greeted by a blue QML dialog

More

Also don’t forget the excellent QML Book for more tutorials.

Along with a very basic YouTube series by Joseph Mills.

Enjoy!

1 Like

Hi Marcus

I’ve done quite a bit of qt using there widgets framework, but I was really interested in getting to know QML and Quick QT.
However we are using Maya, Nuke and the new 3dsMax 2017 and they are all using Qt4.8, which I understand to have quick qt 1 instead of 2.

What would you suggest in this regard. Is it worth getting familiar with Quick Qt 1? I came across your build of PyQt5 for python 2.7 which works fine standalone, but crashed nuke instantly which I guess would to be expected.

How are you using qml with your integrations?

thanks
Phil

In a word, no.

QtQuick pre-5.0 are extremely premature and uninteresting in terms of technology and what you are actually able to achieve with it. You would not see much improvement in terms of results or effort.

Since 5.0, QtQuick has drastically leaped forward to become a well suited successor to GUI development with Qt. But, as you said, most of the DCC software are still on 4.8, so what now?

If we ignore for now the fact that each new increment of most DCC software will build upon Qt 5.6 and above, as per the vfx-platform specification, with pyblish-qml the solution was interprocess communication.

pyblish-qml runs in an independent Python interpreter with PyQt5, and visualises data coming from Maya and others by communicating remotely, in this case by making RPC calls to and from the GUI.

The decision was made so as to not depend on software featuring an integration with Qt and build one GUI fit for all. The vast majority of development time in this case was spent external to the software in which it was used, so it made sense long-term at the time.

Now, in retrospect, whether it was the right decision or not is questionable, as there has been numerous other unforeseen issues with way it has to manage it’s interprocess communication. Some of it due to inexperience, some of it due to mere complexity.

Apart from all this, I have personal interest in the technology, OpenGL and “edgy” graphical user interface design (I want this) which is also a strong motivator.

So if you’re asking whether you should go with widgets or go with QML for your next project, my recommendation would be to go with widgets for hack-and-slash tools, for tools you need many artists and TDs to understand and develop, and go for QML when you (a) need to unleash the artist in you and/or (b) when you expect to build and maintain it long term. Widgets are dead and no longer developed, at some point this will no longer be a choice.

1 Like

Those Interfaces are awesome!
Thank you very much for the detailed response, that’s really helpful. I wont bother with QML in QT4.8.
I’m not sure I want to go down the route of running the interface in a separate python interpreter unless I have to, like in the cases of adobe products. I imagine you run into issues of parenting as well as other things. But I do really like the look of what you can do with QML, I might give it a go as a side project, and see how things turn out. Thanks again

In the interest of growing these references for when the world of VFX goes entirely Qt 5, here’s another introductory text on communicating between QML and Python.

1 Like