Qt and Designer

What is Qt?

  • Qt is a framework for application development. It has a robust C++ library/API for creating tools and apps of all sizes.

  • Qt is cross-platform meaning you can run your application on Windows, Linux, macOS, and even make applications for mobile.

What is Qt Designer?

  • Designer is a tool for designing user interfaces.

  • The Qt Group describe Designer as what-you-see-is-what-you-get (WYSISWYG).

  • Designer gives you visual control over components such as layouts, widget arrangement, and widget look.

What is PyQt and PySide?

  • PyQt and PySide are Python bindings for Qt.

  • Most, not all of the modules in C++ are available in Python.

What are the main differences between the two?

  • PyQt and PySide are essentially the same thing; most of the code is interchangeable when switching between the two.

  • PySide was developed to be licenses under LGPL so it could be easily packaged and redistributed in commercial projects.

  • PySide was slower in catching up with the development of PyQt so PyQt was adopted faster. There is plenty of documentation and examples for PyQt because of this.

  • PySide is now the official Python binding supported by the Qt Group.

  • The way .ui files are loaded between the two is different.

# Loading .ui file via PyQt
import sys
from PyQt5 import QtWidgets, uic

app = QtWidgets.QApplication(sys.argv)
window = uic.loadUi(r"C:\path\to\main_window.ui")
window.show()
app.exec()
# Loading .ui file via PySide
import sys
from PySide2 import QtUiTools, QtWidgets

app = QtWidgets.QApplication(sys.argv)
ui_loader = QtUiTools.QUiLoader()
window = ui_loader.load(r"C:\path\to\main_window.ui", None)
window.show()
app.exec_()

Why do we use the Qt framework?

  • It's one of the most commonly used frameworks for tool development in our industry.

  • PySide is commonly packaged with our DCC software like Maya and Houdini.

  • It's very easy to prototype or whip up a UI using Qt Designer. This makes it very easy to maintain and update. Iteration is very important so being able to spend less time fussing with pixels and more time focused on the functionality of the tool.

  • You can create software agnostic UIs. A single UI that can be invoked in Maya, MotionBuilder, and Houdini can also be invoked outside of any application.

  • The look/theme of the interface can be controlled using CSS. You can create a stylesheet that is shared by all of your tools.

Three ways to create a UI

  1. Write the UI strictly through Python without the use of a .ui file.

  2. Create the UI in Qt Designer as a .ui file, convert the .ui file to a py file, and then import the widgets and classes using standard Python imports.

  3. Create the UI in Qt Designer as a .ui file, in your script that invokes the UI, load the .ui file.

Next
Next

Maya: Modifying the Native Interface