From dfb6fbed7c2262ffb02dfe609c7a45aba48a98ac Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 24 Jun 2019 16:34:36 +0200 Subject: [PATCH] "New Class" wizard: Add option for adding the Q_OBJECT macro This lets users specify that a class derived from a custom base should have a Q_OBJECT macro, and it also allows them to opt out of it for classes derived directly from QObject & friends. Fixes: QTCREATORBUG-21810 Change-Id: I850bd3bcb7b6eb71720afe5fa097178ff5d5c620 Reviewed-by: hjk --- share/qtcreator/templates/wizards/classes/cpp/file.h | 2 +- .../templates/wizards/classes/cpp/wizard.json | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/share/qtcreator/templates/wizards/classes/cpp/file.h b/share/qtcreator/templates/wizards/classes/cpp/file.h index 583c63dd30e..6f38dc98383 100644 --- a/share/qtcreator/templates/wizards/classes/cpp/file.h +++ b/share/qtcreator/templates/wizards/classes/cpp/file.h @@ -28,7 +28,7 @@ class %{CN} : public %{Base} class %{CN} @endif { -@if %{isQObject} +@if '%{AddQObjectMacro}' Q_OBJECT @endif public: diff --git a/share/qtcreator/templates/wizards/classes/cpp/wizard.json b/share/qtcreator/templates/wizards/classes/cpp/wizard.json index 85218814836..18755802470 100644 --- a/share/qtcreator/templates/wizards/classes/cpp/wizard.json +++ b/share/qtcreator/templates/wizards/classes/cpp/wizard.json @@ -132,6 +132,17 @@ "checked": false } }, + { + "name": "AddQObjectMacro", + "trDisplayName": "Add Q_OBJECT", + "type": "CheckBox", + "data": + { + "checkedValue": "AddQObjectMacro", + "uncheckedValue": "", + "checked": "%{JS: [ 'QObject', 'QWidget', 'QMainWindow', 'QDeclarativeItem', 'QQuickItem'].indexOf(value('Base')) >= 0 }" + } + }, { "name": "Sp2", "type": "Spacer"