aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/templates
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2019-05-27 10:54:50 +0200
committerChristian Stenger <christian.stenger@qt.io>2019-05-27 11:35:37 +0000
commit84b34a41e736c272caa0adf56aed11d14b825d61 (patch)
tree1639db01f1cda30c9129da357bbdaa7ef8bbe243 /share/qtcreator/templates
parentf6ac2c8e751c8b0f62cd9cd9c481c9d0ca6543b0 (diff)
Wizard: Make the default generated template runnable
If one uses the Python - Window template and does not explicitly change the custom base class to an existing the generated project lacks some essential stuff. Make the generated main file usable even for first time users. Change-Id: I898189fd4edff88f13987d6d1df9f77e2ef6bd68 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'share/qtcreator/templates')
-rw-r--r--share/qtcreator/templates/wizards/projects/qtforpythonapplication/main_mainwindow.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/share/qtcreator/templates/wizards/projects/qtforpythonapplication/main_mainwindow.py b/share/qtcreator/templates/wizards/projects/qtforpythonapplication/main_mainwindow.py
index d72da8a272..9ec8b5d4e5 100644
--- a/share/qtcreator/templates/wizards/projects/qtforpythonapplication/main_mainwindow.py
+++ b/share/qtcreator/templates/wizards/projects/qtforpythonapplication/main_mainwindow.py
@@ -6,6 +6,9 @@ from PySide2.QtWidgets import QApplication, QWidget
@if '%{BaseCB}' === 'QMainWindow'
from PySide2.QtWidgets import QApplication, QMainWindow
@endif
+@if '%{BaseCB}' === ''
+from PySide2.QtWidgets import QApplication
+@endif
@if '%{BaseCB}'
@@ -20,10 +23,17 @@ class %{Class}:
@if '%{BaseCB}' === 'QMainWindow'
QMainWindow.__init__(self)
@endif
+@if '%{BaseCB}' === ''
+ pass # call __init__(self) of the custom base class here
+@endif
if __name__ == "__main__":
app = QApplication([])
window = %{Class}()
+@if '%{BaseCB}' === ''
+ # window.show()
+@else
window.show()
+@endif
sys.exit(app.exec_())