From 4f2844f31f852a94cbdaa6de2f2e7a719473634a Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Thu, 28 Jul 2011 16:51:00 +0200 Subject: Fixed external link to DevNet Wiki. Reviewed-by: Geir Vattekar --- doc/src/qt-webpages.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/qt-webpages.qdoc b/doc/src/qt-webpages.qdoc index c993575..f67ff83 100644 --- a/doc/src/qt-webpages.qdoc +++ b/doc/src/qt-webpages.qdoc @@ -221,7 +221,7 @@ \title Forums on Qt Developer Network */ /*! - \externalpage http://developer.qt.nokia.com/wikis + \externalpage http://developer.qt.nokia.com/wiki \title Wiki on Qt Developer Network */ /*! -- cgit v0.12 From 8815bc982b8361517a4376db4eb0e1b402c2bd65 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 29 Jul 2011 12:03:07 +0200 Subject: Doc: Fixes to Qt tutorial Reviewed-by: Jerome Pasion --- doc/src/getting-started/gettingstartedqt.qdoc | 72 ++++++++++++++-------- .../tutorials/gettingStarted/gsQt/part2/main.cpp | 14 ++--- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/doc/src/getting-started/gettingstartedqt.qdoc b/doc/src/getting-started/gettingstartedqt.qdoc index eda5ee1..d37e8e0 100644 --- a/doc/src/getting-started/gettingstartedqt.qdoc +++ b/doc/src/getting-started/gettingstartedqt.qdoc @@ -38,6 +38,12 @@ documentation, and find the information you need for the application you are developing. + The code for this tutorial is available in \c + {examples/tutorials/gettingStarted/gsQt} under your Qt + installation. If you are using the Qt SDK, you will find it in + \c{Examples/4.7/tutorials/gettingStarted/gsQt} (change \c{4.7} if + you are using a later Qt version). + \section1 Hello Notepad In this first example, we simply create and show a text edit in a @@ -139,28 +145,28 @@ Let us take a look at the code. \code - 1 #include - 2 - 3 int main(int argv, char **args) - 4 { - 5 QApplication app(argv, args); - 6 - 7 QTextEdit textEdit; - 8 QPushButton quitButton("Quit"); - 9 -10 QObject::connect(&quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); -11 -12 QVBoxLayout layout; -13 layout.addWidget(&textEdit); -14 layout.addWidget(&quitButton); -15 -16 QWidget window; -17 window.setLayout(&layout); -18 -19 window.show(); -20 -21 return app.exec(); -22 } + 1 #include + 2 + 3 int main(int argv, char **args) + 4 { + 5 QApplication app(argv, args); + 6 + 7 QTextEdit *textEdit = new QTextEdit; + 8 QPushButton *quitButton = new QPushButton("&Quit"); + 9 +10 QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); +11 +12 QVBoxLayout *layout = new QVBoxLayout; +13 layout->addWidget(textEdit); +14 layout->addWidget(quitButton); +15 +16 QWidget window; +17 window.setLayout(layout); +18 +19 window.show(); +20 +21 return app.exec(); +22 } \endcode Line 1 includes QtGui, which contains all of Qt's GUI classes. @@ -278,9 +284,25 @@ visible strings. This function is necessary when you want to provide your application in more than one language (e.g. English and Chinese). We will not go into details here, but you can follow - the \c {Qt Linguist} link from the learn more table. We will not - look at the implementation of \c quit() slot and the \c main() - function, but you can check out the source code if you want to. + the \c {Qt Linguist} link from the learn more table. + + Here is the \c quit() slot: + + \code +75 void Notepad::quit() +76 { +77 QMessageBox messageBox; +78 messageBox.setWindowTitle(tr("Notepad")); +79 messageBox.setText(tr("Do you really want to quit?")); +80 messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); +81 messageBox.setDefaultButton(QMessageBox::No); +82 if (messageBox.exec() == QMessageBox::Yes) +83 qApp->quit(); +84 } + \endcode + + We use the QMessageBox class to display a dialog that asks the + user whether he/she really wants to quit. \section2 Learn More diff --git a/examples/tutorials/gettingStarted/gsQt/part2/main.cpp b/examples/tutorials/gettingStarted/gsQt/part2/main.cpp index 24b4d77..afa26e1 100755 --- a/examples/tutorials/gettingStarted/gsQt/part2/main.cpp +++ b/examples/tutorials/gettingStarted/gsQt/part2/main.cpp @@ -44,17 +44,17 @@ int main(int argv, char **args) { QApplication app(argv, args); - QTextEdit textEdit; - QPushButton quitButton("&Quit"); + QTextEdit *textEdit = new QTextEdit; + QPushButton *quitButton = new QPushButton("&Quit"); - QObject::connect(&quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); + QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); - QVBoxLayout layout; - layout.addWidget(&textEdit); - layout.addWidget(&quitButton); + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(textEdit); + layout->addWidget(quitButton); QWidget window; - window.setLayout(&layout); + window.setLayout(layout); window.show(); -- cgit v0.12