forked from qt-creator/qt-creator
Add Qt for Python templates
Qt for Python * Add files with basic statements to execute a QApplication using ".ui" files * Add files with basic statements to execute a QtQuick application Task-number: QTCREATORBUG-21824 Change-Id: I6e69d82f2a6ba9c67ede96b36ecf4421f30f169f Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"supportedProjectTypes": [ "PythonProject" ],
|
||||
"id": "U.QtForPythonApplicationEmpty",
|
||||
"id": "F.QtForPythonApplicationEmpty",
|
||||
"category": "F.Application",
|
||||
"trDescription": "Creates a Qt for Python application that contains only the main code for a QApplication.",
|
||||
"trDisplayName": "Qt for Python - Empty",
|
||||
"trDisplayCategory": "Application",
|
||||
"icon": "icon.png",
|
||||
"enabled": "%{JS: value('Plugins').indexOf('Python') >= 0}",
|
||||
"featuresRequired": [ "QtSupport.Wizards.FeatureQt.5.6" ],
|
||||
|
||||
"options":
|
||||
[
|
||||
@@ -44,6 +43,11 @@
|
||||
"source": "../main_empty.py",
|
||||
"target": "%{SrcFileName}",
|
||||
"openInEditor": true
|
||||
},
|
||||
{
|
||||
"source": "../../git.ignore",
|
||||
"target": ".gitignore",
|
||||
"condition": "%{JS: !value('IsSubproject') && value('VersionControl') === 'G.Git'}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 855 B After Width: | Height: | Size: 855 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,16 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
import sys
|
||||
import os
|
||||
|
||||
from PySide2.QtGui import QGuiApplication
|
||||
from PySide2.QtQml import QQmlApplicationEngine
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QGuiApplication(sys.argv)
|
||||
engine = QQmlApplicationEngine()
|
||||
engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))
|
||||
|
||||
if not engine.rootObjects():
|
||||
sys.exit(-1)
|
||||
sys.exit(app.exec_())
|
@@ -0,0 +1,40 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
@if '%{BaseCB}' === 'QWidget'
|
||||
from PySide2.QtWidgets import QApplication, QWidget
|
||||
@endif
|
||||
@if '%{BaseCB}' === 'QMainWindow'
|
||||
from PySide2.QtWidgets import QApplication, QMainWindow
|
||||
@endif
|
||||
@if '%{BaseCB}' === 'QDialog'
|
||||
from PySide2.QtWidgets import QApplication, QDialog
|
||||
@endif
|
||||
from PySide2.QtCore import QFile
|
||||
from PySide2.QtUiTools import QUiLoader
|
||||
|
||||
|
||||
@if '%{BaseCB}'
|
||||
class %{Class}(%{BaseCB}):
|
||||
@else
|
||||
class %{Class}:
|
||||
@endif
|
||||
def __init__(self):
|
||||
super(%{Class}, self).__init__()
|
||||
self.load_ui()
|
||||
|
||||
def load_ui(self):
|
||||
loader = QUiLoader()
|
||||
path = os.path.join(os.path.dirname(__file__), "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}()
|
||||
widget.show()
|
||||
sys.exit(app.exec_())
|
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>%{Class}</class>
|
||||
<widget class="%{BaseCB}" name="%{Class}">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>%{Class}</string>
|
||||
</property>
|
||||
@if '%{BaseCB}' === 'QMainWindow'
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar"/>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
@endif
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@@ -1,14 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"supportedProjectTypes": [ "PythonProject" ],
|
||||
"id": "U.QtForPythonApplicationWindow",
|
||||
"id": "F.QtForPythonApplicationWindow",
|
||||
"category": "F.Application",
|
||||
"trDescription": "Creates a Qt for Python application that contains an empty window.",
|
||||
"trDisplayName": "Qt for Python - Window",
|
||||
"trDisplayCategory": "Application",
|
||||
"icon": "icon.png",
|
||||
"icon": "../icons/icon.png",
|
||||
"enabled": "%{JS: value('Plugins').indexOf('Python') >= 0}",
|
||||
"featuresRequired": [ "QtSupport.Wizards.FeatureQt.5.6" ],
|
||||
|
||||
"options":
|
||||
[
|
||||
@@ -43,8 +42,8 @@
|
||||
"type": "ComboBox",
|
||||
"data":
|
||||
{
|
||||
"items": [ { "trKey": "<Custom>", "value": "" },
|
||||
"QWidget", "QMainWindow"]
|
||||
"items": [ "QWidget", "QMainWindow",
|
||||
{ "trKey": "<Custom>", "value": "" } ]
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -84,6 +83,11 @@
|
||||
"source": "../main_mainwindow.py",
|
||||
"target": "%{MainPyFileName}",
|
||||
"openInEditor": true
|
||||
},
|
||||
{
|
||||
"source": "../../git.ignore",
|
||||
"target": ".gitignore",
|
||||
"condition": "%{JS: !value('IsSubproject') && value('VersionControl') === 'G.Git'}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"files": ["%{SrcFileName}", "%{QmlFileName}"]
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
import QtQuick %{QtQuickVersion}
|
||||
import QtQuick.Window %{QtQuickWindowVersion}
|
||||
|
||||
Window {
|
||||
title: qsTr("Hello World")
|
||||
width: 640
|
||||
height: 480
|
||||
visible: true
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"version": 1,
|
||||
"supportedProjectTypes": [ "PythonProject" ],
|
||||
"id": "F.QtQuickQtForPythonApplicationEmpty",
|
||||
"category": "F.Application",
|
||||
"trDescription": "Creates a Qt Quick application that contains an empty window.",
|
||||
"trDisplayName": "Qt for Python - Qt Quick Application - Empty",
|
||||
"trDisplayCategory": "Application",
|
||||
"icon": "../icons/icon.png",
|
||||
"enabled": "%{JS: value('Plugins').indexOf('Python') >= 0}",
|
||||
|
||||
"options":
|
||||
[
|
||||
{ "key": "SrcFileName", "value": "main.py" },
|
||||
{ "key": "QmlFileName", "value": "main.qml" },
|
||||
{ "key": "PyProjectFile", "value": "main.pyproject" },
|
||||
{ "key": "QtQuickVersion", "value": "%{JS: value('QtVersion').QtQuickVersion}" },
|
||||
{ "key": "QtQuickWindowVersion", "value": "%{JS: value('QtVersion').QtQuickWindowVersion}" }
|
||||
],
|
||||
|
||||
"pages":
|
||||
[
|
||||
{
|
||||
"trDisplayName": "Project Location",
|
||||
"trShortTitle": "Location",
|
||||
"typeId": "Project"
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Define Project Details",
|
||||
"trShortTitle": "Details",
|
||||
"typeId": "Fields",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"name": "QtVersion",
|
||||
"trDisplayName": "PySide version:",
|
||||
"type": "ComboBox",
|
||||
"data":
|
||||
{
|
||||
"index": 1,
|
||||
"items":
|
||||
[
|
||||
{
|
||||
"trKey": "PySide 5.13",
|
||||
"value":
|
||||
{
|
||||
"QtQuickVersion": "2.13",
|
||||
"QtQuickWindowVersion": "2.13"
|
||||
}
|
||||
},
|
||||
{
|
||||
"trKey": "PySide 5.12",
|
||||
"value":
|
||||
{
|
||||
"QtQuickVersion": "2.12",
|
||||
"QtQuickWindowVersion": "2.12"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Project Management",
|
||||
"trShortTitle": "Summary",
|
||||
"typeId": "Summary"
|
||||
}
|
||||
],
|
||||
"generators":
|
||||
[
|
||||
{
|
||||
"typeId": "File",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"source": "../main_qtquick.py",
|
||||
"target": "main.py"
|
||||
},
|
||||
{
|
||||
"source": "main.pyproject",
|
||||
"target": "main.pyproject",
|
||||
"openAsProject": true
|
||||
},
|
||||
{
|
||||
"source": "main.qml.tpl",
|
||||
"target": "main.qml",
|
||||
"openInEditor": true
|
||||
},
|
||||
{
|
||||
"source": "../../git.ignore",
|
||||
"target": ".gitignore",
|
||||
"condition": "%{JS: !value('IsSubproject') && value('VersionControl') === 'G.Git'}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"files": ["%{SrcFileName}", "form.ui"]
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"version": 1,
|
||||
"supportedProjectTypes": [ "PythonProject" ],
|
||||
"id": "F.QtForPythonApplicationWindowWidget",
|
||||
"category": "F.Application",
|
||||
"trDescription": "Creates a Qt for Python application that includes a Qt Designer-based widget (ui file)",
|
||||
"trDisplayName": "Qt for Python - Window (UI file)",
|
||||
"trDisplayCategory": "Application",
|
||||
"icon": "../icons/icon.png",
|
||||
"enabled": "%{JS: value('Plugins').indexOf('Python') >= 0}",
|
||||
|
||||
"options":
|
||||
[
|
||||
{ "key": "SrcFileName", "value": "main.py" },
|
||||
{ "key": "PyProjectFile", "value": "main.pyproject" }
|
||||
],
|
||||
|
||||
"pages":
|
||||
[
|
||||
{
|
||||
"trDisplayName": "Project Location",
|
||||
"trShortTitle": "Location",
|
||||
"typeId": "Project",
|
||||
"name": "ProjectPath"
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Define Class",
|
||||
"trShortTitle": "Details",
|
||||
"typeId": "Fields",
|
||||
"data" :
|
||||
[
|
||||
{
|
||||
"name": "Class",
|
||||
"trDisplayName": "Class name:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data": { "validator": "(?:(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*|)" }
|
||||
},
|
||||
{
|
||||
"name": "BaseCB",
|
||||
"trDisplayName": "Base class:",
|
||||
"type": "ComboBox",
|
||||
"data":
|
||||
{
|
||||
"items": [ "QWidget", "QDialog", "QMainWindow" ]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "SrcFileName",
|
||||
"type": "LineEdit",
|
||||
"trDisplayName": "Source file:",
|
||||
"mandatory": true,
|
||||
"data": { "trText": "%{JS: Cpp.classToFileName(value('Class'), Util.preferredSuffix('text/x-python'))}" }
|
||||
},
|
||||
{
|
||||
"name": "ProjectFileName",
|
||||
"type": "LineEdit",
|
||||
"trDisplayName": "Project file:",
|
||||
"mandatory": true,
|
||||
"data": { "trText": "%{JS: Cpp.classToFileName(value('Class'), 'pyproject')}" }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Project Management",
|
||||
"trShortTitle": "Summary",
|
||||
"typeId": "Summary"
|
||||
}
|
||||
],
|
||||
"generators":
|
||||
[
|
||||
{
|
||||
"typeId": "File",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"source": "main.pyproject",
|
||||
"target": "%{PyProjectFile}",
|
||||
"openAsProject": true
|
||||
},
|
||||
{
|
||||
"source": "../main_widget.py",
|
||||
"target": "%{SrcFileName}",
|
||||
"openInEditor": true
|
||||
},
|
||||
{
|
||||
"source": "../main_widget.ui",
|
||||
"target": "form.ui"
|
||||
},
|
||||
{
|
||||
"source": "../../git.ignore",
|
||||
"target": ".gitignore",
|
||||
"condition": "%{JS: !value('IsSubproject') && value('VersionControl') === 'G.Git'}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user