diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-05-22 09:28:05 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-05-22 09:28:05 (GMT) |
commit | d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d (patch) | |
tree | ba6df139b3c343bb9352423770a99f218f62bd45 /examples/tutorials | |
parent | 72798fc4dfc1af73cde542f9017dfec5cb020173 (diff) | |
parent | 8ad5020940f10d4ecc5c5e8b3b9656531cb84ef3 (diff) | |
download | Qt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.zip Qt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.tar.gz Qt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-animations
Conflicts:
src/corelib/kernel/kernel.pri
src/corelib/kernel/qvariant_p.h
src/corelib/tools/tools.pri
src/gui/graphicsview/qgraphicsitem.cpp
src/gui/graphicsview/qgraphicsitem.h
src/gui/graphicsview/qgraphicswidget.h
src/gui/gui.pro
Diffstat (limited to 'examples/tutorials')
23 files changed, 349 insertions, 28 deletions
diff --git a/examples/tutorials/addressbook-fr/part1/main.cpp b/examples/tutorials/addressbook-fr/part1/main.cpp index 22bfd3e..9c96882 100644 --- a/examples/tutorials/addressbook-fr/part1/main.cpp +++ b/examples/tutorials/addressbook-fr/part1/main.cpp @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part2/main.cpp b/examples/tutorials/addressbook-fr/part2/main.cpp index 22bfd3e..9c96882 100644 --- a/examples/tutorials/addressbook-fr/part2/main.cpp +++ b/examples/tutorials/addressbook-fr/part2/main.cpp @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part3/main.cpp b/examples/tutorials/addressbook-fr/part3/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook-fr/part3/main.cpp +++ b/examples/tutorials/addressbook-fr/part3/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part4/main.cpp b/examples/tutorials/addressbook-fr/part4/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook-fr/part4/main.cpp +++ b/examples/tutorials/addressbook-fr/part4/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part5/main.cpp b/examples/tutorials/addressbook-fr/part5/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook-fr/part5/main.cpp +++ b/examples/tutorials/addressbook-fr/part5/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part6/main.cpp b/examples/tutorials/addressbook-fr/part6/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook-fr/part6/main.cpp +++ b/examples/tutorials/addressbook-fr/part6/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part7/main.cpp b/examples/tutorials/addressbook-fr/part7/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook-fr/part7/main.cpp +++ b/examples/tutorials/addressbook-fr/part7/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part1/main.cpp b/examples/tutorials/addressbook/part1/main.cpp index 22bfd3e..9c96882 100644 --- a/examples/tutorials/addressbook/part1/main.cpp +++ b/examples/tutorials/addressbook/part1/main.cpp @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part2/main.cpp b/examples/tutorials/addressbook/part2/main.cpp index 22bfd3e..9c96882 100644 --- a/examples/tutorials/addressbook/part2/main.cpp +++ b/examples/tutorials/addressbook/part2/main.cpp @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part3/main.cpp b/examples/tutorials/addressbook/part3/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook/part3/main.cpp +++ b/examples/tutorials/addressbook/part3/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part4/main.cpp b/examples/tutorials/addressbook/part4/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook/part4/main.cpp +++ b/examples/tutorials/addressbook/part4/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part5/main.cpp b/examples/tutorials/addressbook/part5/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook/part5/main.cpp +++ b/examples/tutorials/addressbook/part5/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part6/main.cpp b/examples/tutorials/addressbook/part6/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook/part6/main.cpp +++ b/examples/tutorials/addressbook/part6/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part7/main.cpp b/examples/tutorials/addressbook/part7/main.cpp index b25d656..46f6f03 100644 --- a/examples/tutorials/addressbook/part7/main.cpp +++ b/examples/tutorials/addressbook/part7/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/widgets/childwidget/childwidget.pro b/examples/tutorials/widgets/childwidget/childwidget.pro new file mode 100644 index 0000000..37ae98e --- /dev/null +++ b/examples/tutorials/widgets/childwidget/childwidget.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/childwidget +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS childwidget.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/childwidget +INSTALLS += target sources diff --git a/examples/tutorials/widgets/childwidget/main.cpp b/examples/tutorials/widgets/childwidget/main.cpp new file mode 100644 index 0000000..fd50b1d --- /dev/null +++ b/examples/tutorials/widgets/childwidget/main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [main program] +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget window; + window.resize(320, 240); + window.setWindowTitle(QApplication::translate("childwidget", "Child widget")); + window.show(); + +//! [create, position and show] + QPushButton *button = new QPushButton( + QApplication::translate("childwidget", "Press me"), &window); + button->move(100, 100); + button->show(); +//! [create, position and show] + return app.exec(); +} +//! [main program] diff --git a/examples/tutorials/widgets/nestedlayouts/main.cpp b/examples/tutorials/widgets/nestedlayouts/main.cpp new file mode 100644 index 0000000..226d0f9 --- /dev/null +++ b/examples/tutorials/widgets/nestedlayouts/main.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [main program] +//! [first part] +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget window; + + QLabel *queryLabel = new QLabel( + QApplication::translate("nestedlayouts", "Query:")); + QLineEdit *queryEdit = new QLineEdit(); + QTableView *resultView = new QTableView(); + + QHBoxLayout *queryLayout = new QHBoxLayout(); + queryLayout->addWidget(queryLabel); + queryLayout->addWidget(queryEdit); + + QVBoxLayout *mainLayout = new QVBoxLayout(); + mainLayout->addLayout(queryLayout); + mainLayout->addWidget(resultView); + window.setLayout(mainLayout); + + // Set up the model and configure the view... +//! [first part] + +//! [set up the model] + QStandardItemModel model; + model.setHorizontalHeaderLabels( + QStringList() << QApplication::translate("nestedlayouts", "Name") + << QApplication::translate("nestedlayouts", "Office")); + + QList<QStringList> rows = QList<QStringList>() + << (QStringList() << "Verne Nilsen" << "123") + << (QStringList() << "Carlos Tang" << "77") + << (QStringList() << "Bronwyn Hawcroft" << "119") + << (QStringList() << "Alessandro Hanssen" << "32") + << (QStringList() << "Andrew John Bakken" << "54") + << (QStringList() << "Vanessa Weatherley" << "85") + << (QStringList() << "Rebecca Dickens" << "17") + << (QStringList() << "David Bradley" << "42") + << (QStringList() << "Knut Walters" << "25") + << (QStringList() << "Andrea Jones" << "34"); + + foreach (QStringList row, rows) { + QList<QStandardItem *> items; + foreach (QString text, row) + items.append(new QStandardItem(text)); + model.appendRow(items); + } + + resultView->setModel(&model); + resultView->verticalHeader()->hide(); + resultView->horizontalHeader()->setStretchLastSection(true); +//! [set up the model] +//! [last part] + window.setWindowTitle( + QApplication::translate("nestedlayouts", "Nested layouts")); + window.show(); + return app.exec(); +} +//! [last part] +//! [main program] diff --git a/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro b/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro new file mode 100644 index 0000000..a7f141c --- /dev/null +++ b/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/nestedlayouts +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS nestedlayouts.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/nestedlayouts +INSTALLS += target sources diff --git a/examples/tutorials/widgets/toplevel/main.cpp b/examples/tutorials/widgets/toplevel/main.cpp new file mode 100644 index 0000000..f18fa6b --- /dev/null +++ b/examples/tutorials/widgets/toplevel/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [main program] +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); +//! [create, resize and show] + QWidget window; + window.resize(320, 240); + window.show(); +//! [create, resize and show] + window.setWindowTitle( + QApplication::translate("toplevel", "Top-level widget")); + return app.exec(); +} +//! [main program] diff --git a/examples/tutorials/widgets/toplevel/toplevel.pro b/examples/tutorials/widgets/toplevel/toplevel.pro new file mode 100644 index 0000000..58d59c5 --- /dev/null +++ b/examples/tutorials/widgets/toplevel/toplevel.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/toplevel +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS toplevel.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/toplevel +INSTALLS += target sources diff --git a/examples/tutorials/widgets/widgets.pro b/examples/tutorials/widgets/widgets.pro new file mode 100644 index 0000000..7a870e7 --- /dev/null +++ b/examples/tutorials/widgets/widgets.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +SUBDIRS = toplevel childwidget windowlayout nestedlayouts + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS widgets.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets +INSTALLS += target sources diff --git a/examples/tutorials/widgets/windowlayout/main.cpp b/examples/tutorials/widgets/windowlayout/main.cpp new file mode 100644 index 0000000..c30d669 --- /dev/null +++ b/examples/tutorials/widgets/windowlayout/main.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [main program] +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget window; +//! [create, lay out widgets and show] + QLabel *label = new QLabel(QApplication::translate("windowlayout", "Name:")); + QLineEdit *lineEdit = new QLineEdit(); + + QHBoxLayout *layout = new QHBoxLayout(); + layout->addWidget(label); + layout->addWidget(lineEdit); + window.setLayout(layout); +//! [create, lay out widgets and show] + window.setWindowTitle( + QApplication::translate("windowlayout", "Window layout")); + window.show(); + return app.exec(); +} +//! [main program] diff --git a/examples/tutorials/widgets/windowlayout/windowlayout.pro b/examples/tutorials/widgets/windowlayout/windowlayout.pro new file mode 100644 index 0000000..408f6ef --- /dev/null +++ b/examples/tutorials/widgets/windowlayout/windowlayout.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/windowlayout +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS windowlayout.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/windowlayout +INSTALLS += target sources |