Skip to content

Instantly share code, notes, and snippets.

@fiskurgit
Last active January 7, 2020 09:47
Show Gist options
  • Save fiskurgit/aa5b1351f08710be7b5d818f442b057c to your computer and use it in GitHub Desktop.
Save fiskurgit/aa5b1351f08710be7b5d818f442b057c to your computer and use it in GitHub Desktop.
Using Qt in Python via QML (instead of inline code) with the Material Design style
import sys
from PySide2.QtQml import QQmlApplicationEngine
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import Qt, QCoreApplication
if __name__ == "__main__":
sys_argv = sys.argv
sys_argv += ['--style', 'Material']
app = QApplication(sys_argv)
engine = QQmlApplicationEngine('view.qml')
sys.exit(app.exec_())
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
ApplicationWindow {
visible: true
Material.theme: Material.Dark
Material.accent: Material.Purple
title: "Qt Hello Material"
width: 640
height: 480
Column {
anchors.centerIn: parent
RadioButton { text: qsTr("Smol") }
RadioButton { text: qsTr("Medium"); checked: true }
RadioButton { text: qsTr("Large") }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment