From e22eea1cf3c9f884d872d4f4c32cd5f320a27786 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 17 Feb 2020 20:13:35 +0100 Subject: [PATCH] Fix the Python templates This fixes the templates so that they do not produce any warnings and also includes QQuickItem in the choice of base classes Change-Id: I58bbd462052f5d2a64bb8c4bea5bbdcd15e66700 Reviewed-by: Cristian Maureira-Fredes --- share/qtcreator/templates/wizards/classes/python/file.py | 7 +++---- .../qtcreator/templates/wizards/classes/python/wizard.json | 2 +- share/qtcreator/templates/wizards/files/python/file.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/share/qtcreator/templates/wizards/classes/python/file.py b/share/qtcreator/templates/wizards/classes/python/file.py index adcbc1ed2d0..5698022dd85 100644 --- a/share/qtcreator/templates/wizards/classes/python/file.py +++ b/share/qtcreator/templates/wizards/classes/python/file.py @@ -21,6 +21,7 @@ from PyQt5 import QtQuick @endif @endif + @if '%{Base}' class %{Class}(%{Base}): @else @@ -29,11 +30,9 @@ class %{Class}: def __init__(self): @if '%{Base}' === 'QWidget' QtWidgets.QWidget.__init__(self) -@endif -@if '%{Base}' === 'QMainWindow' +@elif '%{Base}' === 'QMainWindow' QtWidgets.QMainWindow.__init__(self) -@if '%{Base}' === 'QQuickItem' +@elif '%{Base}' === 'QQuickItem' QtQuick.QQuickItem.__init__(self) @endif pass - diff --git a/share/qtcreator/templates/wizards/classes/python/wizard.json b/share/qtcreator/templates/wizards/classes/python/wizard.json index 552c3f15a0e..aeebd1f2a30 100644 --- a/share/qtcreator/templates/wizards/classes/python/wizard.json +++ b/share/qtcreator/templates/wizards/classes/python/wizard.json @@ -46,7 +46,7 @@ "data": { "items": [ { "trKey": "", "value": "" }, - "QObject", "QWidget", "QMainWindow", "QDeclarativeItem" ] + "QObject", "QWidget", "QMainWindow", "QDeclarativeItem", "QQuickItem" ] } }, { diff --git a/share/qtcreator/templates/wizards/files/python/file.py b/share/qtcreator/templates/wizards/files/python/file.py index 003f8414973..fcb605f9f72 100644 --- a/share/qtcreator/templates/wizards/files/python/file.py +++ b/share/qtcreator/templates/wizards/files/python/file.py @@ -1,4 +1,4 @@ # This Python file uses the following encoding: utf-8 -# if__name__ == "__main__": +# if __name__ == "__main__": # pass