Last active
October 23, 2016 09:28
-
-
Save akdasa/086abb725390229f9a2c3bacae6d4036 to your computer and use it in GitHub Desktop.
Simple PyQt5/QML application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function log() { | |
console.log("HELLO!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import related modules | |
import QtQuick 2.3 | |
import QtQuick.Controls 1.2 | |
import QtQuick.Window 2.2 | |
import "application.js" as App | |
//window containing the application | |
ApplicationWindow { | |
//title of the application | |
title: qsTr("Hello World") | |
width: 640 | |
height: 480 | |
//a button in the middle of the content area | |
Button { | |
id: btn | |
text: qsTr("Hello World") | |
anchors.horizontalCenter: parent.horizontalCenter | |
anchors.verticalCenter: parent.verticalCenter | |
onClicked: App.log() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
from PyQt5.QtWidgets import QApplication | |
from PyQt5.QtQml import QQmlApplicationEngine | |
if __name__ == '__main__': | |
full_directory = os.path.dirname(os.path.abspath(__file__)) | |
app = QApplication(sys.argv) | |
engine = QQmlApplicationEngine() | |
qml_file = os.path.join(full_directory, "basic.qml") | |
engine.load(str(qml_file)) | |
window = engine.rootObjects()[0] | |
window.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment