diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2009-08-21 12:56:57 (GMT) |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2009-08-21 12:56:57 (GMT) |
commit | 34679dd23213881a9632e21e4858377ff90a9006 (patch) | |
tree | deb9ebf681d4954b2d44858ca1a14d251c31e8eb /doc | |
parent | 7669f91c33328505fbe52f4913bd3f8745b76d31 (diff) | |
parent | 4aa6869877d4906fcfaac5388294748512cace25 (diff) | |
download | Qt-34679dd23213881a9632e21e4858377ff90a9006.zip Qt-34679dd23213881a9632e21e4858377ff90a9006.tar.gz Qt-34679dd23213881a9632e21e4858377ff90a9006.tar.bz2 |
Merge branch 'master' of git@scm.dev.troll.no:qt/qt-s60-public
Conflicts:
src/corelib/io/qfilesystemwatcher_symbian.cpp
src/corelib/io/qfilesystemwatcher_symbian_p.h
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/examples/qtscriptcalculator.qdoc | 6 | ||||
-rw-r--r-- | doc/src/examples/qxmlstreambookmarks.qdoc | 42 | ||||
-rw-r--r-- | doc/src/howtos/restoring-geometry.qdoc | 39 | ||||
-rw-r--r-- | doc/src/scripting/scripting.qdoc | 38 | ||||
-rw-r--r-- | doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp | 19 |
5 files changed, 62 insertions, 82 deletions
diff --git a/doc/src/examples/qtscriptcalculator.qdoc b/doc/src/examples/qtscriptcalculator.qdoc index 0e6e153..7adce5a 100644 --- a/doc/src/examples/qtscriptcalculator.qdoc +++ b/doc/src/examples/qtscriptcalculator.qdoc @@ -89,10 +89,8 @@ \snippet examples/script/calculator/calculator.js 1 - The digitClicked() function uses the special local variable - __qt_sender__ to access the object that triggered the signal; - this gives us a simple way to retrieve the value of the digit - that was clicked. + The digitClicked() function is called when a digit button is + clicked, with the input digit as argument. \snippet examples/script/calculator/calculator.js 2 diff --git a/doc/src/examples/qxmlstreambookmarks.qdoc b/doc/src/examples/qxmlstreambookmarks.qdoc index 26964c4..904cd6d 100644 --- a/doc/src/examples/qxmlstreambookmarks.qdoc +++ b/doc/src/examples/qxmlstreambookmarks.qdoc @@ -51,10 +51,10 @@ \section1 XbelWriter Class Definition - The \c XbelWriter class is a subclass of QXmlStreamReader, which provides - an XML parser with a streaming API. \c XbelWriter also contains a private - instance of QTreeWidget in order to display the bookmarks according to - hierarchies. + The \c XbelWriter class contains a private instance of QXmlStreamWriter, + which provides an XML writer with a streaming API. \c XbelWriter also + has a reference to the QTreeWidget instance where the bookmark hierarchy + is stored. \snippet examples/xml/streambookmarks/xbelwriter.h 0 @@ -75,7 +75,7 @@ \snippet examples/xml/streambookmarks/xbelwriter.cpp 1 - The \c writeItem() function accepts a QTreeWidget object and writes it + The \c writeItem() function accepts a QTreeWidgetItem object and writes it to the stream, depending on its \c tagName, which can either be a "folder", "bookmark", or "separator". @@ -83,9 +83,10 @@ \section1 XbelReader Class Definition - The \c XbelReader class is a subclass of QXmlStreamReader, the pendent - class for QXmlStreamWriter. \c XbelReader contains a private instance - of QTreeWidget to group bookmarks according to their hierarchies. + The \c XbelReader contains a private instance of QXmlStreamReader, the + companion class to QXmlStreamWriter. \c XbelReader also contains a + reference to the QTreeWidget that is used to group the bookmarks according + to their hierarchy. \snippet examples/xml/streambookmarks/xbelreader.h 0 @@ -102,21 +103,26 @@ \snippet examples/xml/streambookmarks/xbelreader.cpp 0 The \c read() function accepts a QIODevice and sets it using - \l{QXmlStreamReader::setDevice()}{setDevice()}. The actual process - of reading only takes place if the file is a valid XBEL 1.0 file. - Note that the XML input needs to be well-formed to be accepted by - QXmlStreamReader. Otherwise, the \l{QXmlStreamReader::raiseError()} - {raiseError()} function is used to display an error message. Since the - XBEL reader is only concerned with reading XML elements, it makes - extensive use of the \l{QXmlStreamReader::readNextStartElement()} + \l{QXmlStreamReader::}{setDevice()}. The actual process of reading only + takes place if the file is a valid XBEL 1.0 file. Note that the XML input + needs to be well-formed to be accepted by QXmlStreamReader. Otherwise, the + \l{QXmlStreamReader::}{raiseError()} function is used to display an error + message. Since the XBEL reader is only concerned with reading XML elements, + it makes extensive use of the \l{QXmlStreamReader::}{readNextStartElement()} convenience function. \snippet examples/xml/streambookmarks/xbelreader.cpp 1 + The \c errorString() function is used if an error occurred, in order to + obtain a description of the error complete with line and column number + information. + + \snippet examples/xml/streambookmarks/xbelreader.cpp 2 + The \c readXBEL() function reads the name of a startElement and calls the appropriate function to read it, depending on whether if its a "folder", "bookmark" or "separator". Otherwise, it calls - \l{QXmlStreamReader::skipCurrentElement()}. The Q_ASSERT() macro is used + \l{QXmlStreamReader::}{skipCurrentElement()}. The Q_ASSERT() macro is used to provide a pre-condition for the function. \snippet examples/xml/streambookmarks/xbelreader.cpp 3 @@ -126,8 +132,8 @@ \snippet examples/xml/streambookmarks/xbelreader.cpp 4 The \c readSeparator() function creates a separator and sets its flags. - The text is set to 30 "0xB7", the HEX equivalent for period, and then - read using \c readElementText(). + The text is set to 30 "0xB7", the HEX equivalent for period. The element + is then skipped using \l{QXmlStreamReader::}{skipCurrentElement()}. \snippet examples/xml/streambookmarks/xbelreader.cpp 5 diff --git a/doc/src/howtos/restoring-geometry.qdoc b/doc/src/howtos/restoring-geometry.qdoc index c9e6f4f..cc6f3e1 100644 --- a/doc/src/howtos/restoring-geometry.qdoc +++ b/doc/src/howtos/restoring-geometry.qdoc @@ -45,25 +45,28 @@ \ingroup best-practices - This document describes how to save and restore a window's - geometry using the geometry properties. On Windows, this is - basically storing the result of QWidget::geometry() and calling - QWidget::setGeometry() in the next session before calling - \l{QWidget::show()}{show()}. + This document describes how to save and restore a \l{Window + Geometry}{window's geometry} using the geometry properties. On + Windows, this is basically storing the result of + QWidget::geometry() and calling QWidget::setGeometry() in the next + session before calling \l{QWidget::show()}{show()}. - On X11, this won't work because an invisible window doesn't have - a frame yet. The window manager will decorate the window later. - When this happens, the window shifts towards the bottom/right - corner of the screen depending on the size of the decoration frame. - Although X provides a way to avoid this shift, most window managers - fail to implement this feature. + On X11, this might not work because an invisible window does not + have a frame yet. The window manager will decorate the window + later. When this happens, the window shifts towards the + bottom/right corner of the screen depending on the size of the + decoration frame. Although X provides a way to avoid this shift, + some window managers fail to implement this feature. Since version 4.2, Qt provides functions that saves and restores a window's geometry and state for you. QWidget::saveGeometry() saves the window geometry and maximized/fullscreen state, while QWidget::restoreGeometry() restores it. The restore function also checks if the restored geometry is outside the available screen - geometry, and modifies it as appropriate if it is. + geometry, and modifies it as appropriate if it is: + + \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 0 + \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 1 If those functions are not available or cannot be used, then a workaround is to call \l{QWidget::setGeometry()}{setGeometry()} @@ -74,14 +77,6 @@ \l{QWidget::pos()}{pos()} and \l{QWidget::size()}{size()} and to restore the geometry using \l{QWidget::resize()} and \l{QWidget::move()}{move()} before calling - \l{QWidget::show()}{show()}, as demonstrated in the following - code snippets (from the \l{mainwindows/application}{Application} - example): - - \snippet examples/mainwindows/application/mainwindow.cpp 35 - \codeline - \snippet examples/mainwindows/application/mainwindow.cpp 38 - - This method works on Windows, Mac OS X, and most X11 window - managers. + \l{QWidget::show()}{show()}, as demonstrated in the + \l{mainwindows/application}{Application} example. */ diff --git a/doc/src/scripting/scripting.qdoc b/doc/src/scripting/scripting.qdoc index 5fcf8b2..2973f09 100644 --- a/doc/src/scripting/scripting.qdoc +++ b/doc/src/scripting/scripting.qdoc @@ -1224,44 +1224,6 @@ for it, evaluate the script, and finally restore the old context. \endlist - \section2 Nested Functions and the Scope Chain - - This is an advanced topic; feel free to skip it. - - A nested function can be used to "capture" the execution context in which a - nested function object is created; this is typically referred to as creating - a \e closure. When, at some later time, the nested function is invoked, it - can access the variables that were created when the enclosing function was - invoked. This can perhaps best be illustrated through a small example: - - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 70 - - The \c{counter()} function initializes a local variable to zero, - and returns a nested function. The nested function increments - the "outer" variable and returns its new value. The variable - persists over function calls, as shown in the following example: - - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 71 - - The \c{counter()} function can be implemented as a native function, too - \mdash or rather, as a pair of native functions: One for the outer and - one for the inner. The definition of the outer function is as follows: - - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 72 - - The function creates a local variable and initializes it to zero. - Then it wraps the inner native function, and sets the scope of - the resulting function object to be the activation object associated - with this (the outer) function call. The inner function accesses - the "outer" activation through the scope of the callee: - - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 73 - - It is also possible to have a hybrid approach, where the outer function - is a native function and the inner function is defined by a script: - - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 74 - \section2 Property Getters and Setters A script object property can be defined in terms of a getter/setter diff --git a/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp new file mode 100644 index 0000000..0e4040a --- /dev/null +++ b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp @@ -0,0 +1,19 @@ +//! [0] +void MyMainWindow::closeEvent(QCloseEvent *event) +{ + QSettings settings("MyCompany", "MyApp"); + settings.setValue("geometry", saveGeometry()); + settings.setValue("windowState", saveState()); + QMainWindow::closeEvent(event); +} +//! [0] + + +//! [1] +void MainWindow::readSettings() +{ + QSettings settings("MyCompany", "MyApp"); + restoreGeometry(settings.value("myWidget/geometry").toByteArray()); + restoreState(settings.value("myWidget/windowState").toByteArray()); +} +//! [1] |