"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 <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-06-24 16:34:36 +02:00
parent 725ed099b7
commit dfb6fbed7c
2 changed files with 12 additions and 1 deletions

View File

@@ -28,7 +28,7 @@ class %{CN} : public %{Base}
class %{CN} class %{CN}
@endif @endif
{ {
@if %{isQObject} @if '%{AddQObjectMacro}'
Q_OBJECT Q_OBJECT
@endif @endif
public: public:

View File

@@ -132,6 +132,17 @@
"checked": false "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", "name": "Sp2",
"type": "Spacer" "type": "Spacer"