forked from qt-creator/qt-creator
Brush up the Python wizard code templates
Fix the spacing and introduce pathlib. Change-Id: I240291d91cae7c233b2d3ec5c0dfaeede09ad47d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
from %{PySideVersion}.QtGui import QGuiApplication
|
||||
from %{PySideVersion}.QtQml import QQmlApplicationEngine
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QGuiApplication(sys.argv)
|
||||
engine = QQmlApplicationEngine()
|
||||
engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))
|
||||
|
||||
engine.load(os.fspath(Path(__file__).resolve().parent / "main.qml"))
|
||||
if not engine.rootObjects():
|
||||
sys.exit(-1)
|
||||
sys.exit(app.exec_())
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
import sys
|
||||
import os
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
@if '%{BaseCB}' === 'QWidget'
|
||||
from %{PySideVersion}.QtWidgets import QApplication, QWidget
|
||||
@@ -27,12 +27,13 @@ class %{Class}:
|
||||
|
||||
def load_ui(self):
|
||||
loader = QUiLoader()
|
||||
path = os.path.join(os.path.dirname(__file__), "form.ui")
|
||||
path = os.fspath(Path(__file__).resolve().parent / "form.ui")
|
||||
ui_file = QFile(path)
|
||||
ui_file.open(QFile.ReadOnly)
|
||||
loader.load(ui_file, self)
|
||||
ui_file.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication([])
|
||||
widget = %{Class}()
|
||||
|
Reference in New Issue
Block a user