diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 09:34:13 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 09:34:13 (GMT) |
commit | 67ad0519fd165acee4a4d2a94fa502e9e4847bd0 (patch) | |
tree | 1dbf50b3dff8d5ca7e9344733968c72704eb15ff /doc/src/snippets/widgets-tutorial | |
download | Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2 |
Long live Qt!
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 0000000..bba41b9 --- /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 0000000..8a97810 --- /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 0000000..f541464 --- /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 0000000..bba41b9 --- /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 0000000..cffdff8 --- /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 0000000..bba41b9 --- /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 0000000..0c6e814 --- /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 0000000..bba41b9 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/windowlayout/windowlayout.pro @@ -0,0 +1 @@ +SOURCES = main.cpp |