diff options
Diffstat (limited to 'doc/codesnippets/doc/src/snippets/quiloader')
6 files changed, 319 insertions, 0 deletions
diff --git a/doc/codesnippets/doc/src/snippets/quiloader/main.cpp b/doc/codesnippets/doc/src/snippets/quiloader/main.cpp new file mode 100644 index 000000000..2365942c8 --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/quiloader/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include <QtUiTools> + +#include "mywidget.h" + +//! [0] +def loadCustomWidget(parent): + loader = QUiLoader() + + availableWidgets = loader.availableWidgets() + + if (availableWidgets.contains("AnalogClock")): + myWidget = loader.createWidget("AnalogClock", parent) + + return myWidget +//! [0] + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + MyWidget widget; + widget.show(); + + QWidget *customWidget = loadCustomWidget(0); + customWidget->show(); + return app.exec(); +} diff --git a/doc/codesnippets/doc/src/snippets/quiloader/myform.ui b/doc/codesnippets/doc/src/snippets/quiloader/myform.ui new file mode 100644 index 000000000..00702e860 --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/quiloader/myform.ui @@ -0,0 +1,130 @@ +<ui version="4.0" > + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>Form</class> + <widget class="QWidget" name="Form" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>258</width> + <height>224</height> + </rect> + </property> + <property name="windowTitle" > + <string>Export Document</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>8</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QGroupBox" name="groupBox" > + <property name="title" > + <string>Export Options</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>8</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="1" column="0" > + <widget class="QRadioButton" name="radioButton_2" > + <property name="text" > + <string>&DocBook</string> + </property> + </widget> + </item> + <item row="0" column="0" > + <widget class="QRadioButton" name="radioButton" > + <property name="text" > + <string>&LaTeX</string> + </property> + <property name="checked" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QCheckBox" name="checkBox_2" > + <property name="text" > + <string>Include p&ictures</string> + </property> + <property name="checked" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="5" column="0" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="1" > + <widget class="QCheckBox" name="checkBox" > + <property name="text" > + <string>&Compress</string> + </property> + </widget> + </item> + <item row="2" column="0" > + <widget class="QRadioButton" name="radioButton_2_2" > + <property name="text" > + <string>&HTML</string> + </property> + </widget> + </item> + <item row="3" column="0" > + <widget class="QRadioButton" name="radioButton_3" > + <property name="text" > + <string>&PostScript</string> + </property> + </widget> + </item> + <item row="4" column="0" > + <widget class="QRadioButton" name="radioButton_4" > + <property name="text" > + <string>PD&F</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QCheckBox" name="checkBox_3" > + <property name="text" > + <string>Include &metadata</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QCheckBox" name="checkBox_4" > + <property name="text" > + <string>Create inde&x</string> + </property> + <property name="checked" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> diff --git a/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp new file mode 100644 index 000000000..26a334361 --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include <QtUiTools> + +#include "mywidget.h" + +//! [0] +class MyWidget(QWidget): + def __init__(self, parent): + loader = QUiLoader() + file = QFile(":/forms/myform.ui") + file.open(QFile.ReadOnly) + myWidget = loader.load(file, self) + file.close() + + layout = QVBoxLayout() + layout.addWidget(myWidget) + self.setLayout(layout) +//! [0] diff --git a/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h new file mode 100644 index 000000000..0d6a774e4 --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYWIDGET_H +#define MYWIDGET_H + +#include <QWidget> + +class MyWidget : public QWidget +{ +public: + MyWidget(QWidget *parent = 0); +}; + +#endif diff --git a/doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc new file mode 100644 index 000000000..47684d68b --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/forms"> +<file>myform.ui</file> +</qresource> +</RCC> diff --git a/doc/codesnippets/doc/src/snippets/quiloader/quiloader.pro b/doc/codesnippets/doc/src/snippets/quiloader/quiloader.pro new file mode 100644 index 000000000..c82d0e5bb --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/quiloader/quiloader.pro @@ -0,0 +1,4 @@ +HEADERS = mywidget.h +SOURCES = main.cpp mywidget.cpp +RESOURCES = mywidget.qrc +CONFIG += uitools |