forked from qt-creator/qt-creator
That is, if the user specifies a custom base class, we check whether its constructor takes a "QObject *parent" parameter, and if it does, we give the derived class one as well. This is technically a heuristic, but the pattern is pretty stable in the Qt world. Fixes: QTCREATORBUG-25156 Change-Id: Ie64440929df61cca7258d6d692c5de62970f9a65 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
%{Cpp:LicenseTemplate}\
|
|
#include "%{JS: Util.relativeFilePath('%{Path}/%{HdrFileName}', '%{Path}' + '/' + Util.path('%{SrcFileName}'))}"
|
|
%{JS: Cpp.openNamespaces('%{Class}')}
|
|
@if '%{IncludeQSharedData}'
|
|
class %{CN}Data : public QSharedData
|
|
{
|
|
public:
|
|
|
|
};
|
|
|
|
@endif
|
|
@if '%{Base}' === 'QObject'
|
|
%{CN}::%{CN}(QObject *parent) : QObject(parent)%{JS: ('%{SharedDataInit}') ? ', %{SharedDataInit}' : ''}
|
|
@elsif '%{Base}' === 'QWidget' || '%{Base}' === 'QMainWindow'
|
|
%{CN}::%{CN}(QWidget *parent) : %{Base}(parent)%{JS: ('%{SharedDataInit}') ? ', %{SharedDataInit}' : ''}
|
|
@elsif %{JS: Cpp.hasQObjectParent('%{Base}')}
|
|
%{CN}::%{CN}(QObject *parent) : %{Base}(parent)%{JS: ('%{SharedDataInit}') ? ', %{SharedDataInit}' : ''}
|
|
@else
|
|
%{CN}::%{CN}()%{JS: ('%{SharedDataInit}') ? ' : %{SharedDataInit}' : ''}
|
|
@endif
|
|
{
|
|
|
|
}
|
|
@if '%{IncludeQSharedData}'
|
|
|
|
%{CN}::%{CN}(const %{CN} &rhs) : data(rhs.data)
|
|
{
|
|
|
|
}
|
|
|
|
%{CN} &%{CN}::operator=(const %{CN} &rhs)
|
|
{
|
|
if (this != &rhs)
|
|
data.operator=(rhs.data);
|
|
return *this;
|
|
}
|
|
|
|
%{CN}::~%{CN}()
|
|
{
|
|
|
|
}
|
|
@endif
|
|
%{JS: Cpp.closeNamespaces('%{Class}')}\
|