From 04765969d74f4e3f323a4477c41b061e954f6df7 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 21 Jan 2011 07:32:05 +0100 Subject: Doc: Added code for GettingStartedQt tutorial Task-number: QTBUG-16609 --- examples/tutorials/gettingStarted/gsQt/gsqt.pro | 14 +++ .../tutorials/gettingStarted/gsQt/part1/main.cpp | 14 +++ .../tutorials/gettingStarted/gsQt/part1/part1.pro | 8 ++ .../tutorials/gettingStarted/gsQt/part2/main.cpp | 24 +++++ .../tutorials/gettingStarted/gsQt/part2/part2.pro | 9 ++ .../tutorials/gettingStarted/gsQt/part3/main.cpp | 58 ++++++++++++ .../tutorials/gettingStarted/gsQt/part3/part3.pro | 9 ++ .../tutorials/gettingStarted/gsQt/part4/main.cpp | 69 ++++++++++++++ .../tutorials/gettingStarted/gsQt/part4/part4.pro | 9 ++ .../tutorials/gettingStarted/gsQt/part5/main.cpp | 105 +++++++++++++++++++++ .../tutorials/gettingStarted/gsQt/part5/part5.pro | 9 ++ .../tutorials/gettingStarted/gsQt/part6/main.cpp | 95 +++++++++++++++++++ .../tutorials/gettingStarted/gsQt/part6/part6.pro | 9 ++ 13 files changed, 432 insertions(+) create mode 100755 examples/tutorials/gettingStarted/gsQt/gsqt.pro create mode 100755 examples/tutorials/gettingStarted/gsQt/part1/main.cpp create mode 100755 examples/tutorials/gettingStarted/gsQt/part1/part1.pro create mode 100755 examples/tutorials/gettingStarted/gsQt/part2/main.cpp create mode 100755 examples/tutorials/gettingStarted/gsQt/part2/part2.pro create mode 100755 examples/tutorials/gettingStarted/gsQt/part3/main.cpp create mode 100755 examples/tutorials/gettingStarted/gsQt/part3/part3.pro create mode 100755 examples/tutorials/gettingStarted/gsQt/part4/main.cpp create mode 100755 examples/tutorials/gettingStarted/gsQt/part4/part4.pro create mode 100755 examples/tutorials/gettingStarted/gsQt/part5/main.cpp create mode 100755 examples/tutorials/gettingStarted/gsQt/part5/part5.pro create mode 100755 examples/tutorials/gettingStarted/gsQt/part6/main.cpp create mode 100755 examples/tutorials/gettingStarted/gsQt/part6/part6.pro diff --git a/examples/tutorials/gettingStarted/gsQt/gsqt.pro b/examples/tutorials/gettingStarted/gsQt/gsqt.pro new file mode 100755 index 0000000..46c4f06 --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/gsqt.pro @@ -0,0 +1,14 @@ +TEMPLATE = subdirs + +SUBDIRS = part1 \ + part2 \ + part3 \ + part4 \ + part5 \ + part6 + +# install +sources.files = *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/gettingStarted/gsQt +INSTALLS += sources + diff --git a/examples/tutorials/gettingStarted/gsQt/part1/main.cpp b/examples/tutorials/gettingStarted/gsQt/part1/main.cpp new file mode 100755 index 0000000..e1eabca --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part1/main.cpp @@ -0,0 +1,14 @@ + +#include + + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + QTextEdit textEdit; + textEdit.show(); + + return app.exec(); +} + diff --git a/examples/tutorials/gettingStarted/gsQt/part1/part1.pro b/examples/tutorials/gettingStarted/gsQt/part1/part1.pro new file mode 100755 index 0000000..f52a633 --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part1/part1.pro @@ -0,0 +1,8 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/gettingStarted/gsQt/part1 +sources.files = $$SOURCES *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorial/gettingStarted/gsQt/part1 +INSTALLS += target sources + diff --git a/examples/tutorials/gettingStarted/gsQt/part2/main.cpp b/examples/tutorials/gettingStarted/gsQt/part2/main.cpp new file mode 100755 index 0000000..2910310 --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part2/main.cpp @@ -0,0 +1,24 @@ + +#include + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + QTextEdit textEdit; + QPushButton quitButton("&Quit"); + + QObject::connect(&quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); + + QVBoxLayout layout; + layout.addWidget(&textEdit); + layout.addWidget(&quitButton); + + QWidget window; + window.setLayout(&layout); + + window.show(); + + return app.exec(); +} + diff --git a/examples/tutorials/gettingStarted/gsQt/part2/part2.pro b/examples/tutorials/gettingStarted/gsQt/part2/part2.pro new file mode 100755 index 0000000..383c3ce --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part2/part2.pro @@ -0,0 +1,9 @@ + +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/gettingStarted/gsQt/part2 +sources.files = $$SOURCES *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorial/gettingStarted/gsQt/part2 +INSTALLS += target sources + diff --git a/examples/tutorials/gettingStarted/gsQt/part3/main.cpp b/examples/tutorials/gettingStarted/gsQt/part3/main.cpp new file mode 100755 index 0000000..238fb94 --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part3/main.cpp @@ -0,0 +1,58 @@ + +#include + +class Notepad : public QWidget +{ + Q_OBJECT + +public: + Notepad(); + +private slots: + void quit(); + +private: + QTextEdit *textEdit; + QPushButton *quitButton; + +}; + +Notepad::Notepad() +{ + textEdit = new QTextEdit; + quitButton = new QPushButton(tr("Quit")); + + connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(textEdit); + layout->addWidget(quitButton); + + setLayout(layout); + + setWindowTitle(tr("Notepad")); +} + +void Notepad::quit() +{ + QMessageBox messageBox; + messageBox.setWindowTitle(tr("Notepad")); + messageBox.setText(tr("Do you really want to quit?")); + messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + messageBox.setDefaultButton(QMessageBox::No); + if (messageBox.exec() == QMessageBox::Yes) + qApp->quit(); +} + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + Notepad notepad; + notepad.show(); + + return app.exec(); +} + +#include "main.moc" + diff --git a/examples/tutorials/gettingStarted/gsQt/part3/part3.pro b/examples/tutorials/gettingStarted/gsQt/part3/part3.pro new file mode 100755 index 0000000..d194acb --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part3/part3.pro @@ -0,0 +1,9 @@ + +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/gettingStarted/gsQt/part3 +sources.files = $$SOURCES *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorial/gettingStarted/gsQt/part3 +INSTALLS += target sources + diff --git a/examples/tutorials/gettingStarted/gsQt/part4/main.cpp b/examples/tutorials/gettingStarted/gsQt/part4/main.cpp new file mode 100755 index 0000000..6bc9638 --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part4/main.cpp @@ -0,0 +1,69 @@ + +#include + +class Notepad : public QMainWindow +{ + Q_OBJECT + +public: + Notepad(); + +private slots: + void load(); + void save(); + +private: + QTextEdit *textEdit; + + QAction *loadAction; + QAction *saveAction; + QAction *exitAction; + + QMenu *fileMenu; +}; + +Notepad::Notepad() +{ + + loadAction = new QAction(tr("&Load"), this); + saveAction = new QAction(tr("&Save"), this); + exitAction = new QAction(tr("E&xit"), this); + + connect(loadAction, SIGNAL(triggered()), this, SLOT(load())); + connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); + connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + + fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->addAction(loadAction); + fileMenu->addAction(saveAction); + fileMenu->addSeparator(); + fileMenu->addAction(exitAction); + + textEdit = new QTextEdit; + setCentralWidget(textEdit); + + setWindowTitle(tr("Notepad")); +} + +void Notepad::load() +{ + +} + +void Notepad::save() +{ + +} + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + Notepad notepad; + notepad.show(); + + return app.exec(); +}; + +#include "main.moc" + diff --git a/examples/tutorials/gettingStarted/gsQt/part4/part4.pro b/examples/tutorials/gettingStarted/gsQt/part4/part4.pro new file mode 100755 index 0000000..3de03ac --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part4/part4.pro @@ -0,0 +1,9 @@ + +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/gettingStarted/gsQt/part4 +sources.files = $$SOURCES *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorial/gettingStarted/gsQt/part4 +INSTALLS += target sources + diff --git a/examples/tutorials/gettingStarted/gsQt/part5/main.cpp b/examples/tutorials/gettingStarted/gsQt/part5/main.cpp new file mode 100755 index 0000000..a97bab8 --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part5/main.cpp @@ -0,0 +1,105 @@ + +#include + +class Notepad : public QMainWindow +{ + Q_OBJECT + +public: + Notepad(); + +private slots: + void newDocument(); + void load(); + void save(); + + void documentChanged(int index); + +private: + QTextEdit *textEdit; + + QAction *newDocumentAction; + QAction *loadAction; + QAction *saveAction; + QAction *exitAction; + + QMenu *fileMenu; + + QDockWidget *dockWidget; + QListWidget *listWidget; + + QStringList documents; + int documentCount; +}; + +Notepad::Notepad() +{ + + newDocumentAction = new QAction(tr("&New"), this); + loadAction = new QAction(tr("&Load"), this); + saveAction = new QAction(tr("&Save"), this); + exitAction = new QAction(tr("E&xit"), this); + + connect(newDocumentAction, SIGNAL(triggered()), this, SLOT(newDocument())); + connect(loadAction, SIGNAL(triggered()), this, SLOT(load())); + connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); + connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + + fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->addAction(newDocumentAction); + fileMenu->addAction(loadAction); + fileMenu->addAction(saveAction); + fileMenu->addSeparator(); + fileMenu->addAction(exitAction); + + textEdit = new QTextEdit; + setCentralWidget(textEdit); + + listWidget = new QListWidget; + + connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(documentChanged(int))); + + dockWidget = new QDockWidget; + dockWidget->setWidget(listWidget); + + addDockWidget(Qt::LeftDockWidgetArea, dockWidget); + + documentCount = 0; + newDocument(); + + setWindowTitle(tr("Notepad")); +} + +void Notepad::documentChanged(int index) +{ + +} + +void Notepad::newDocument() +{ + listWidget->addItem(tr("Document %1").arg(documentCount++)); + documents.append(""); +} + +void Notepad::load() +{ + +} + +void Notepad::save() +{ + +} + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + Notepad notepad; + notepad.show(); + + return app.exec(); +}; + +#include "main.moc" + diff --git a/examples/tutorials/gettingStarted/gsQt/part5/part5.pro b/examples/tutorials/gettingStarted/gsQt/part5/part5.pro new file mode 100755 index 0000000..711cac2 --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part5/part5.pro @@ -0,0 +1,9 @@ + +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/gettingStarted/gsQt/part5 +sources.files = $$SOURCES *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorial/gettingStarted/gsQt/part5 +INSTALLS += target sources + diff --git a/examples/tutorials/gettingStarted/gsQt/part6/main.cpp b/examples/tutorials/gettingStarted/gsQt/part6/main.cpp new file mode 100755 index 0000000..ef1217b --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part6/main.cpp @@ -0,0 +1,95 @@ + +#include + +class Notepad : public QMainWindow +{ + Q_OBJECT + +public: + Notepad(); + +private slots: + void open(); + void save(); + +private: + QTextEdit *textEdit; + + QAction *openAction; + QAction *saveAction; + QAction *exitAction; + + QMenu *fileMenu; +}; + +Notepad::Notepad() +{ + + openAction = new QAction(tr("&Load"), this); + saveAction = new QAction(tr("&Save"), this); + exitAction = new QAction(tr("E&xit"), this); + + connect(openAction, SIGNAL(triggered()), this, SLOT(open())); + connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); + connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + + fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->addAction(openAction); + fileMenu->addAction(saveAction); + fileMenu->addSeparator(); + fileMenu->addAction(exitAction); + + textEdit = new QTextEdit; + setCentralWidget(textEdit); + + setWindowTitle(tr("Notepad")); +} + +void Notepad::open() +{ + QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", + tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); + + if (fileName != "") { + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) { + QMessageBox::critical(this, tr("Error"), tr("Could not open file")); + return; + } + QTextStream in(&file); + textEdit->setText(in.readAll()); + file.close(); + } +} + +void Notepad::save() +{ + + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "", + tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); + + if (fileName != "") { + QFile file(fileName); + if (!file.open(QIODevice::WriteOnly)) { + // error message + } else { + QTextStream stream(&file); + stream << textEdit->toPlainText(); + stream.flush(); + file.close(); + } + } +} + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + Notepad notepad; + notepad.show(); + + return app.exec(); +} + +#include "main.moc" + diff --git a/examples/tutorials/gettingStarted/gsQt/part6/part6.pro b/examples/tutorials/gettingStarted/gsQt/part6/part6.pro new file mode 100755 index 0000000..a7861f9 --- /dev/null +++ b/examples/tutorials/gettingStarted/gsQt/part6/part6.pro @@ -0,0 +1,9 @@ + +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/gettingStarted/gsQt/part6 +sources.files = $$SOURCES *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorial/gettingStarted/gsQt/part6 +INSTALLS += target sources + -- cgit v0.12 From 9be58993bc60cd874068010a920706f2f2868955 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 21 Jan 2011 08:45:25 +0100 Subject: Doc: Work on GettingStartedQt tutorial Task-number: QTBUG-16609 --- doc/src/getting-started/gettingstartedqt.qdoc | 224 +++++++++++---------- examples/tutorials/gettingStarted/gsQt/gsqt.pro | 3 +- .../tutorials/gettingStarted/gsQt/part1/main.cpp | 39 ++++ .../tutorials/gettingStarted/gsQt/part2/main.cpp | 39 ++++ .../tutorials/gettingStarted/gsQt/part3/main.cpp | 39 ++++ .../tutorials/gettingStarted/gsQt/part4/main.cpp | 39 ++++ .../tutorials/gettingStarted/gsQt/part5/main.cpp | 117 +++++++---- .../tutorials/gettingStarted/gsQt/part6/main.cpp | 95 --------- .../tutorials/gettingStarted/gsQt/part6/part6.pro | 9 - 9 files changed, 344 insertions(+), 260 deletions(-) delete mode 100755 examples/tutorials/gettingStarted/gsQt/part6/main.cpp delete mode 100755 examples/tutorials/gettingStarted/gsQt/part6/part6.pro diff --git a/doc/src/getting-started/gettingstartedqt.qdoc b/doc/src/getting-started/gettingstartedqt.qdoc index 2800be0..18f85f1 100644 --- a/doc/src/getting-started/gettingstartedqt.qdoc +++ b/doc/src/getting-started/gettingstartedqt.qdoc @@ -105,12 +105,13 @@ This will leave an executable in the \c part1 directory (note that on Windows, you may have to use \c nmake instead of \c make. Also, - the executable will be placed in part1/debug or part1/release). \c - qmake is Qt's build tool, which takes a configuration file. \c - qmake generates this for us when given the \c{-project} argument. - Given the configuration file (suffixed .pro), \c qmake produces a - \c make file that will build the program for you. We will look - into writing our own \c .pro files later. + the executable will be placed in part1\\debug or part1\\release + (these directories are created when you run \c make). \c qmake is + Qt's build tool, which takes a configuration file. \c qmake + generates this for us when given the \c{-project} argument. Given + the configuration file (suffixed .pro), \c qmake produces a \c + make file that will build the program for you. We will look into + writing our own \c .pro files later. \section2 Learn More @@ -245,28 +246,28 @@ parameter types and invoke it. Line 13 declares the slot \c quit(). This is easy using the \c - slots macro. The \c quit() slot can now be connected to signals - with a matching signature (any signal that takes no parameters). + slots macro. The \c quit() slot can now be connected to signals. + We will do that later. Instead of setting up the GUI and connecting the slot in the \c main() function, we now use \c{Notepad}'s constructor. \code - Notepad::Notepad() - { - textEdit = new QTextEdit; - quitButton = new QPushButton(tr("Quit")); - - connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(textEdit); - layout->addWidget(quitButton); - - setLayout(layout); - - setWindowTitle(tr("Notepad")); - } +20 Notepad::Notepad() +21 { +22 textEdit = new QTextEdit; +23 quitButton = new QPushButton(tr("Quit")); +24 +25 connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); +26 +27 QVBoxLayout *layout = new QVBoxLayout; +28 layout->addWidget(textEdit); +29 layout->addWidget(quitButton); +30 +31 setLayout(layout); +32 +33 setWindowTitle(tr("Notepad")); +34 } \endcode As you saw in the class definition, we use pointers to our \l @@ -277,7 +278,9 @@ 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. + 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. \section2 Learn More @@ -305,9 +308,9 @@ using \c qmake's \c -project option. \code - HEADERS = notepad.h - SOURCES = notepad.cpp \ - main.cpp + 1 HEADERS = notepad.h + 2 SOURCES = notepad.cpp \ + 3 main.cpp \endcode The following shell commands build the example. @@ -330,29 +333,29 @@ Let us look at the new \c Notepad class definition. \code - #include - - class Notepad : public QMainWindow - { - Q_OBJECT - - public: - Notepad(); - - private slots: - void open(); - void save(); - void quit(); - - private: - QTextEdit *textEdit; - - QAction *openAction; - QAction *saveAction; - QAction *exitAction; - - QMenu *fileMenu; - }; + 2 #include + 3 + 4 class Notepad : public QMainWindow + 5 { + 6 Q_OBJECT + 7 + 8 public: + 9 Notepad(); +10 +11 private slots: +12 void open(); +13 void save(); +14 void quit(); +15 +16 private: +17 QTextEdit *textEdit; +18 +19 QAction *openAction; +20 QAction *saveAction; +21 QAction *exitAction; +22 +23 QMenu *fileMenu; +24 }; \endcode We include two more slots that can save and open a document. We @@ -369,27 +372,27 @@ GUI. \code - Notepad::Notepad() - { - saveAction = new QAction(tr("&Open"), this); - saveAction = new QAction(tr("&Save"), this); - exitAction = new QAction(tr("E&xit"), this); - - connect(openAction, SIGNAL(triggered()), this, SLOT(open())); - connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); - connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(openAction); - fileMenu->addAction(saveAction); - fileMenu->addSeparator(); - fileMenu->addAction(exitAction); - - textEdit = new QTextEdit; - setCentralWidget(textEdit); - - setWindowTitle(tr("Notepad")); - } +25 Notepad::Notepad() +26 { +27 saveAction = new QAction(tr("&Open"), this); +28 saveAction = new QAction(tr("&Save"), this); +29 exitAction = new QAction(tr("E&xit"), this); +30 +31 connect(openAction, SIGNAL(triggered()), this, SLOT(open())); +32 connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); +33 connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); +34 +35 fileMenu = menuBar()->addMenu(tr("&File")); +36 fileMenu->addAction(openAction); +37 fileMenu->addAction(saveAction); +38 fileMenu->addSeparator(); +39 fileMenu->addAction(exitAction); +40 +41 textEdit = new QTextEdit; +42 setCentralWidget(textEdit); +43 +44 setWindowTitle(tr("Notepad")); +45 } \endcode \l{QAction}s are created with the text that should appear on the @@ -426,28 +429,29 @@ We will start with the \c open() slot: \code - QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", - tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); - - if (fileName != "") { - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly)) { - QMessageBox::critical(this, tr("Error"), - tr("Could not open file")); - return; - } - QString contents = file.readAll().constData(); - textEdit->setPlainText(contents); - file.close(); - } +48 void Notepad::open() +49 { +50 QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", +51 tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); +52 +53 if (fileName != "") { +54 QFile file(fileName); +55 if (!file.open(QIODevice::ReadOnly)) { +56 QMessageBox::critical(this, tr("Error"), tr("Could not open file")); +57 return; +58 } +59 QTextStream in(&file); +60 textEdit->setText(in.readAll()); +61 file.close(); +62 } +63 } \endcode The first step is asking the user for the name of the file to open. Qt comes with QFileDialog, which is a dialog from which the user can select a file. The image above shows the dialog on Kubuntu. The static \l{QFileDialog::}{getOpenFileName()} function - displays a modal file dialog, and does not return until the user - has selected a file. It returns the file path of the file + displays a modal file dialog. It returns the file path of the file selected, or an empty string if the user canceled the dialog. If we have a file name, we try to open the file with @@ -458,38 +462,38 @@ message (see the QMessageBox class description for further details). - Actually reading in the data is trivial using the - \l{QIODevice::}{readAll()} function, which returns all data in the - file in a QByteArray. The \l{QByteArray::}{constData()} returns all - data in the array as a const char*, which QString has a - constructor for. The contents can then be displayed in the text + Actually reading in the data is trivial using the QTextStream + class, which wraps the QFile object. The + \l{QTextStream::}{readAll()} function returns the contents of the + file as a QString. The contents can then be displayed in the text edit. We then \l{QIODevice::}{close()} the file to return the file descriptor back to the operating system. Now, let us move on to the the \c save() slot. \code - QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "", - tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); - - if (fileName != "") { - QFile file(fileName); - if (!file.open(QIODevice::WriteOnly)) { - // error message - } else { - QTextStream stream(&file); - stream << textEdit->toPlainText(); - stream.flush(); - file.close(); - } - } +65 void Notepad::save() +66 { +67 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "", +68 tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); +69 +70 if (fileName != "") { +71 QFile file(fileName); +72 if (!file.open(QIODevice::WriteOnly)) { +73 // error message +74 } else { +75 QTextStream stream(&file); +76 stream << textEdit->toPlainText(); +77 stream.flush(); +78 file.close(); +79 } +80 } +81 } \endcode When we write the contents of the text edit to the file, we use - the QTextStream class, which wraps the QFile object. The text - stream can write QStrings directly to the file; QFile only accepts - raw data (char*) with the \l{QIODevice::}{write()} functions of - QIODevice. + the QTextStream class again. QTextStream can also write + \l{QString}s to the file with the << operator. \section2 Learn More diff --git a/examples/tutorials/gettingStarted/gsQt/gsqt.pro b/examples/tutorials/gettingStarted/gsQt/gsqt.pro index 46c4f06..72f09c1 100755 --- a/examples/tutorials/gettingStarted/gsQt/gsqt.pro +++ b/examples/tutorials/gettingStarted/gsQt/gsqt.pro @@ -4,8 +4,7 @@ SUBDIRS = part1 \ part2 \ part3 \ part4 \ - part5 \ - part6 + part5 # install sources.files = *.pro diff --git a/examples/tutorials/gettingStarted/gsQt/part1/main.cpp b/examples/tutorials/gettingStarted/gsQt/part1/main.cpp index e1eabca..eaf0425 100755 --- a/examples/tutorials/gettingStarted/gsQt/part1/main.cpp +++ b/examples/tutorials/gettingStarted/gsQt/part1/main.cpp @@ -1,3 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ #include diff --git a/examples/tutorials/gettingStarted/gsQt/part2/main.cpp b/examples/tutorials/gettingStarted/gsQt/part2/main.cpp index 2910310..24b4d77 100755 --- a/examples/tutorials/gettingStarted/gsQt/part2/main.cpp +++ b/examples/tutorials/gettingStarted/gsQt/part2/main.cpp @@ -1,3 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ #include diff --git a/examples/tutorials/gettingStarted/gsQt/part3/main.cpp b/examples/tutorials/gettingStarted/gsQt/part3/main.cpp index 238fb94..59ff9c4 100755 --- a/examples/tutorials/gettingStarted/gsQt/part3/main.cpp +++ b/examples/tutorials/gettingStarted/gsQt/part3/main.cpp @@ -1,3 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ #include diff --git a/examples/tutorials/gettingStarted/gsQt/part4/main.cpp b/examples/tutorials/gettingStarted/gsQt/part4/main.cpp index 6bc9638..ba18afb 100755 --- a/examples/tutorials/gettingStarted/gsQt/part4/main.cpp +++ b/examples/tutorials/gettingStarted/gsQt/part4/main.cpp @@ -1,3 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ #include diff --git a/examples/tutorials/gettingStarted/gsQt/part5/main.cpp b/examples/tutorials/gettingStarted/gsQt/part5/main.cpp index a97bab8..4a6257d 100755 --- a/examples/tutorials/gettingStarted/gsQt/part5/main.cpp +++ b/examples/tutorials/gettingStarted/gsQt/part5/main.cpp @@ -1,3 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ #include @@ -9,45 +48,32 @@ public: Notepad(); private slots: - void newDocument(); - void load(); + void open(); void save(); - void documentChanged(int index); - private: QTextEdit *textEdit; - QAction *newDocumentAction; - QAction *loadAction; + QAction *openAction; QAction *saveAction; QAction *exitAction; QMenu *fileMenu; - - QDockWidget *dockWidget; - QListWidget *listWidget; - - QStringList documents; - int documentCount; }; Notepad::Notepad() { - newDocumentAction = new QAction(tr("&New"), this); - loadAction = new QAction(tr("&Load"), this); + openAction = new QAction(tr("&Load"), this); saveAction = new QAction(tr("&Save"), this); exitAction = new QAction(tr("E&xit"), this); - connect(newDocumentAction, SIGNAL(triggered()), this, SLOT(newDocument())); - connect(loadAction, SIGNAL(triggered()), this, SLOT(load())); + connect(openAction, SIGNAL(triggered()), this, SLOT(open())); connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(newDocumentAction); - fileMenu->addAction(loadAction); + fileMenu->addAction(openAction); fileMenu->addAction(saveAction); fileMenu->addSeparator(); fileMenu->addAction(exitAction); @@ -55,40 +81,43 @@ Notepad::Notepad() textEdit = new QTextEdit; setCentralWidget(textEdit); - listWidget = new QListWidget; - - connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(documentChanged(int))); - - dockWidget = new QDockWidget; - dockWidget->setWidget(listWidget); - - addDockWidget(Qt::LeftDockWidgetArea, dockWidget); - - documentCount = 0; - newDocument(); - setWindowTitle(tr("Notepad")); } -void Notepad::documentChanged(int index) -{ - -} - -void Notepad::newDocument() +void Notepad::open() { - listWidget->addItem(tr("Document %1").arg(documentCount++)); - documents.append(""); -} - -void Notepad::load() -{ - + QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", + tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); + + if (fileName != "") { + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) { + QMessageBox::critical(this, tr("Error"), tr("Could not open file")); + return; + } + QTextStream in(&file); + textEdit->setText(in.readAll()); + file.close(); + } } void Notepad::save() { + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "", + tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); + + if (fileName != "") { + QFile file(fileName); + if (!file.open(QIODevice::WriteOnly)) { + // error message + } else { + QTextStream stream(&file); + stream << textEdit->toPlainText(); + stream.flush(); + file.close(); + } + } } int main(int argv, char **args) @@ -99,7 +128,7 @@ int main(int argv, char **args) notepad.show(); return app.exec(); -}; +} #include "main.moc" diff --git a/examples/tutorials/gettingStarted/gsQt/part6/main.cpp b/examples/tutorials/gettingStarted/gsQt/part6/main.cpp deleted file mode 100755 index ef1217b..0000000 --- a/examples/tutorials/gettingStarted/gsQt/part6/main.cpp +++ /dev/null @@ -1,95 +0,0 @@ - -#include - -class Notepad : public QMainWindow -{ - Q_OBJECT - -public: - Notepad(); - -private slots: - void open(); - void save(); - -private: - QTextEdit *textEdit; - - QAction *openAction; - QAction *saveAction; - QAction *exitAction; - - QMenu *fileMenu; -}; - -Notepad::Notepad() -{ - - openAction = new QAction(tr("&Load"), this); - saveAction = new QAction(tr("&Save"), this); - exitAction = new QAction(tr("E&xit"), this); - - connect(openAction, SIGNAL(triggered()), this, SLOT(open())); - connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); - connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(openAction); - fileMenu->addAction(saveAction); - fileMenu->addSeparator(); - fileMenu->addAction(exitAction); - - textEdit = new QTextEdit; - setCentralWidget(textEdit); - - setWindowTitle(tr("Notepad")); -} - -void Notepad::open() -{ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", - tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); - - if (fileName != "") { - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly)) { - QMessageBox::critical(this, tr("Error"), tr("Could not open file")); - return; - } - QTextStream in(&file); - textEdit->setText(in.readAll()); - file.close(); - } -} - -void Notepad::save() -{ - - QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "", - tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); - - if (fileName != "") { - QFile file(fileName); - if (!file.open(QIODevice::WriteOnly)) { - // error message - } else { - QTextStream stream(&file); - stream << textEdit->toPlainText(); - stream.flush(); - file.close(); - } - } -} - -int main(int argv, char **args) -{ - QApplication app(argv, args); - - Notepad notepad; - notepad.show(); - - return app.exec(); -} - -#include "main.moc" - diff --git a/examples/tutorials/gettingStarted/gsQt/part6/part6.pro b/examples/tutorials/gettingStarted/gsQt/part6/part6.pro deleted file mode 100755 index a7861f9..0000000 --- a/examples/tutorials/gettingStarted/gsQt/part6/part6.pro +++ /dev/null @@ -1,9 +0,0 @@ - -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/gettingStarted/gsQt/part6 -sources.files = $$SOURCES *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/tutorial/gettingStarted/gsQt/part6 -INSTALLS += target sources - -- cgit v0.12 From 03bba9491f361548a42c5d0110ddd69693059a25 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 21 Jan 2011 09:11:19 +0100 Subject: Doc: Said that QTimer::start() stops running timer Task-number: QTBUG-16690 --- src/corelib/kernel/qtimer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 3efeda2..b23da3a 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -205,6 +205,9 @@ QTimer::~QTimer() Starts or restarts the timer with the timeout specified in \l interval. + If the timer is already running, it will be + \l{QTimer::stop()}{stopped} and restarted. + If \l singleShot is true, the timer will be activated only once. */ void QTimer::start() @@ -218,6 +221,12 @@ void QTimer::start() /*! Starts or restarts the timer with a timeout interval of \a msec milliseconds. + + If the timer is already running, it will be + \l{QTimer::stop()}{stopped} and restarted. + + If \l singleShot is true, the timer will be activated only once. + */ void QTimer::start(int msec) { -- cgit v0.12 From e0217bf3117b5c75400ff9a55513e0da82d9f579 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 21 Jan 2011 09:25:58 +0100 Subject: Doc: authenticationRequired() cannot use QuedConnection Task-number: QTBUG-16052 --- src/network/access/qnetworkaccessmanager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 27b7945..c870483 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -296,6 +296,10 @@ static void ensureInitialized() again, without emitting the authenticationRequired() signal. If it rejects the credentials, this signal will be emitted again. + \note It is not possible to use a QueuedConnection to connect to + this signal, as the connection will fail if the authenticator has + not been filled in with new information when the signal returns. + \sa proxyAuthenticationRequired() */ -- cgit v0.12 From 06a29fdb81a9ccb992062acf8ecd36b7e97494a3 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 21 Jan 2011 10:10:26 +0100 Subject: Doc: Mentioned the QQ Parenthesis article in two examples Task-number: QTBUG-15668 --- doc/src/examples/codeeditor.qdoc | 4 +++- doc/src/examples/syntaxhighlighter.qdoc | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/src/examples/codeeditor.qdoc b/doc/src/examples/codeeditor.qdoc index 23a2fd4..c4c72c0 100644 --- a/doc/src/examples/codeeditor.qdoc +++ b/doc/src/examples/codeeditor.qdoc @@ -190,6 +190,8 @@ used to implement parenthesis matching. In the \c highlightCurrentLine(), the data of the currentBlock() can be fetched with QTextBlock::userData(). Matching parentheses can be - highlighted with an extra selection. + highlighted with an extra selection. The "Matching Parentheses + with QSyntaxHighlighter" article in Qt Quarterly 31 implements + this. You find it here: \l{http://doc.qt.nokia.com/qq/}. */ diff --git a/doc/src/examples/syntaxhighlighter.qdoc b/doc/src/examples/syntaxhighlighter.qdoc index 4018be8..2511900 100644 --- a/doc/src/examples/syntaxhighlighter.qdoc +++ b/doc/src/examples/syntaxhighlighter.qdoc @@ -239,4 +239,14 @@ function. The QSyntaxHighlighter class also provides the \l {QSyntaxHighlighter::document()}{document()} function which returns the currently set document. + + \section1 Other Code Editor Features + + It is possible to implement parenthesis matching with + QSyntaxHighlighter. The "Matching Parentheses with + QSyntaxHighlighter" article in Qt Quarterly 31 + (\l{http://doc.qt.nokia.com/qq/}) implements this. We also have + the \l{Code Editor Example}, which shows how to implement line + numbers and how to highlight the current line. + */ -- cgit v0.12