diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 10:18:55 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 10:18:55 +0100 |
commit | e5fcad302d86d316390c6b0f62759a067313e8a9 (patch) | |
tree | c2afbf6f1066b6ce261f14341cf6d310e5595bc1 /doc/src/snippets/widgets-tutorial | |
download | qt4-tools-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz |
Long live Qt 4.5!
Diffstat (limited to 'doc/src/snippets/widgets-tutorial')
8 files changed, 101 insertions, 0 deletions
diff --git a/doc/src/snippets/widgets-tutorial/childwidget/childwidget.pro b/doc/src/snippets/widgets-tutorial/childwidget/childwidget.pro new file mode 100644 index 0000000000..bba41b9c12 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/childwidget/childwidget.pro @@ -0,0 +1 @@ +SOURCES = main.cpp diff --git a/doc/src/snippets/widgets-tutorial/childwidget/main.cpp b/doc/src/snippets/widgets-tutorial/childwidget/main.cpp new file mode 100644 index 0000000000..8a97810f02 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/childwidget/main.cpp @@ -0,0 +1,17 @@ +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget *window = new QWidget(); + window->resize(320, 240); + window->setWindowTitle(tr("Child widget")); + window->show(); + +//! [create, position and show] + QPushButton *button = new QPushButton(tr("Press me"), window); + button->move(100, 100); + button->show(); +//! [create, position and show] + return app.exec(); +} diff --git a/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp b/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp new file mode 100644 index 0000000000..f541464901 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp @@ -0,0 +1,48 @@ +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget *window = new QWidget(); +//! [create, lay out widgets and show] + QLabel *queryLabel = new QLabel(tr("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); +//! [create, lay out widgets and show] + + QStandardItemModel model; + model.setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("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); + window->setWindowTitle(tr("Nested layouts")); + window->show(); + return app.exec(); +} diff --git a/doc/src/snippets/widgets-tutorial/nestedlayouts/nestedlayouts.pro b/doc/src/snippets/widgets-tutorial/nestedlayouts/nestedlayouts.pro new file mode 100644 index 0000000000..bba41b9c12 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/nestedlayouts/nestedlayouts.pro @@ -0,0 +1 @@ +SOURCES = main.cpp diff --git a/doc/src/snippets/widgets-tutorial/toplevel/main.cpp b/doc/src/snippets/widgets-tutorial/toplevel/main.cpp new file mode 100644 index 0000000000..cffdff8851 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/toplevel/main.cpp @@ -0,0 +1,13 @@ +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); +//! [create, resize and show] + QWidget *window = new QWidget(); + window->resize(320, 240); + window->show(); +//! [create, resize and show] + window->setWindowTitle(tr("Top-level widget")); + return app.exec(); +} diff --git a/doc/src/snippets/widgets-tutorial/toplevel/toplevel.pro b/doc/src/snippets/widgets-tutorial/toplevel/toplevel.pro new file mode 100644 index 0000000000..bba41b9c12 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/toplevel/toplevel.pro @@ -0,0 +1 @@ +SOURCES = main.cpp diff --git a/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp b/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp new file mode 100644 index 0000000000..0c6e814754 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp @@ -0,0 +1,19 @@ +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget *window = new QWidget(); +//! [create, lay out widgets and show] + QLabel *label = new QLabel(tr("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(tr("Window layout")); + window->show(); + return app.exec(); +} diff --git a/doc/src/snippets/widgets-tutorial/windowlayout/windowlayout.pro b/doc/src/snippets/widgets-tutorial/windowlayout/windowlayout.pro new file mode 100644 index 0000000000..bba41b9c12 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/windowlayout/windowlayout.pro @@ -0,0 +1 @@ +SOURCES = main.cpp |