Commit f3eb0983 authored by Friedemann Kleint's avatar Friedemann Kleint

Wizards/CustomWizard: Add examples.

Task-number: QTCREATORBUG-423
parent 1606cf1b
Qt Creator custom wizard are located in this directory.
The subdirectories 'helloworld' and 'listmodel' are provided as examples.
To see how they work in Qt Creator, rename the 'wizard_sample.xml' files
to 'wizard.xml'.
#include <cstdio>
int main(int, char **)
{
std::printf("%MESSAGE%\n");
return 0;
}
QT -= core
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
Custom project wizard configuration example file. Note that by convention,
the project file goes last.
The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
leave room for the Qt 4 target page.
-->
<wizard version="1" kind="project"
class="qt4project" firstpage="10"
id="A.HelloWorld" category="B.CustomProjects">
<icon>console.png</icon>
<description>Creates a hello-world-project with custom message.</description>
<description xml:lang="de">Erzeugt ein Hello-Welt-Projekt mit einer Nachricht.</description>
<displayName>Hello World</displayName>;
<displayName xml:lang="de">Hallo Welt</displayName>;
<displayCategory>Custom Projects</displayCategory>
<displayCategory xml:lang="de">Benutzerdefinierte Projekte</displayCategory>
<files>
<file source="main.cpp"/>
<file source="project.pro" target="%ProjectName%.pro"/>
</files>
<!-- Create a 2nd wizard page with parameters -->
<fieldpagetitle>Hello World Parameters</fieldpagetitle>
<fieldpagetitle xml:lang="de">Hallo Welt Parameter</fieldpagetitle>
<fields>
<field mandatory="true" name="MESSAGE">
<fieldcontrol class="QLineEdit" validator='^[^"]+$' defaulttext="Hello world!" />
<fielddescription>Hello world message:</fielddescription>
<fielddescription xml:lang="de">Hallo-Welt-Nachricht:</fielddescription>
</field>
</fields>
</wizard>
#include "%ClassName:l%.%CppHeaderSuffix%"
%ClassName%::%ClassName%(QObject *parent) :
QAbstractListModel(parent)
{
}
void %ClassName%::addItems(const QList<%Datatype%> &newItems)
{
beginInsertRows(QModelIndex(), items.size(), items.size() + newItems.size());
items.append(newItems);
endInsertRows();
}
int %ClassName%::rowCount(const QModelIndex &) const
{
return items.size();
}
QVariant %ClassName%::data(const QModelIndex &index, int)
{
return items.at(index.row());
}
#ifndef %ClassName:u%_H
#define %ClassName:u%_H
#include <QAbstractListModel>
#include <QList>
class %ClassName% : public QAbstractListModel {
Q_OBJECT
public:
explicit %ClassName%(QObject *parent);
void addItems(const QList<%Datatype%> &items);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole);
private:
QList<%Datatype%> items;
};
#endif // %ClassName:u%_H
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
Custom class wizard example configuration file. -->
<wizard version="1" kind="class" id="A.ListModel" category="B.CustomClasses">
<description>Creates a QAbstractListModel implementation.</description>
<description xml:lang="de">Erzeugt eine Implementierung von QAbstractListModel.</description>
<displayName>QAbstractListModel implementation</displayName>;
<displayName xml:lang="de">Implementierung von QAbstractListModel</displayName>;
<displayCategory>Custom Classes</displayCategory>
<displayCategory xml:lang="de">Benutzerdefinierte Klassen</displayCategory>
<files>
<file source="listmodel.cpp" target="%ClassName:l%.%CppSourceSuffix%"/>
<file source="listmodel.h" target="%ClassName:l%.%CppHeaderSuffix%"/>
</files>
<!-- Create parameter wizard page -->
<fieldpagetitle>ListModel parameters</fieldpagetitle>
<fieldpagetitle xml:lang="de">Parameter des ListModel</fieldpagetitle>
<fields>
<field name="ClassName">
<fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$" defaulttext="MyListModel" />
<fielddescription>Class name:</fielddescription>
<fielddescription xml:lang="de">Klassenname:</fielddescription>
</field>
<field name="Datatype">
<fieldcontrol class="QComboBox" combochoices="QString,int" defaultindex="0" />
<fielddescription>Data type:</fielddescription>
<fielddescription xml:lang="de">Datentyp:</fielddescription>
</field>
</fields>
</wizard>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment