diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-12-03 10:48:08 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:47:55 -0300 |
commit | 885386fdba018286912d7f3efb3da347e4c80a83 (patch) | |
tree | 4c0ea729e9e73bc6c3f39441f1dcc25de19dbec4 /doc/codesnippets/doc/src/snippets/code | |
parent | 0220d7d1768353f062ef7af10845686f1327923e (diff) |
Updates to more code snippets on documentation concerning QtCore module.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'doc/codesnippets/doc/src/snippets/code')
5 files changed, 83 insertions, 8 deletions
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp index de0fd50ed..98c930374 100644 --- a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp +++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp @@ -31,7 +31,7 @@ def create(fileName): //! [2] # @arg filters QDir.Filters -# @arg filterNames QStringList +# @arg filterNames [str, ...] # @return QAbstractFileEngineIterator def beginEntryList(filters, filterNames): return CustomFileEngineIterator(filters, filterNames) diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp index a849e488b..1de2168c5 100644 --- a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp +++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp @@ -66,8 +66,8 @@ s = dir.relativeFilePath("/home/mary/file.txt") # s is "../mary/file.txt" //! [8] -QDir.setSearchPaths("icons", QStringList(QDir.homePath() + "/images")) -QDir.setSearchPaths("docs", QStringList(":/embeddedDocuments")) +QDir.setSearchPaths("icons", [QDir.homePath() + "/images"]) +QDir.setSearchPaths("docs", [":/embeddedDocuments"]) ... pixmap = QPixmap("icons:undo.png") # will look for undo.png in QDir::homePath() + "/images" file = QFile("docs:design.odf") # will look in the :/embeddedDocuments resource path diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp index 228a24cb5..6b97e37c1 100644 --- a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp +++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp @@ -4,10 +4,10 @@ def wrapInFunction(): //! [0] builder = QProcess() builder.setProcessChannelMode(QProcess.MergedChannels) -builder.start("make", QStringList() << "-j2") +builder.start("make", ["-j2"]) import sys -if !builder.waitForFinished(): +if not builder.waitForFinished(): sys.stderr.write("Make failed:" + builder.errorString()) else sys.stderr.write("Make output:" + builder.readAll()) @@ -57,7 +57,7 @@ class SandboxProcess(QProcess): //! [5] process = QProcess() process.start("del /s *.txt") -# same as process.start("del", QStringList() << "/s" << "*.txt") +# same as process.start("del", ["/s", "*.txt"]) ... //! [5] @@ -76,8 +76,8 @@ process.start("dir \"\"\"My Documents\"\"\"") //! [8] environment = QProcess.systemEnvironment() -# environment = {"PATH=/usr/bin:/usr/local/bin", -# "USER=greg", "HOME=/home/greg"} +# environment = [PATH=/usr/bin:/usr/local/bin", +# "USER=greg", "HOME=/home/greg"] //! [8] diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp index 61ea36233..1f20c3be3 100644 --- a/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp +++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp @@ -26,3 +26,23 @@ beginInsertColumns(parent, 6, 8) //! [5] beginRemoveColumns(parent, 4, 6) //! [5] + + +//! [6] +beginMoveRows(sourceParent, 2, 4, destinationParent, 2) +//! [6] + + +//! [7] +beginMoveRows(sourceParent, 2, 4, destinationParent, 6) +//! [7] + + +//! [8] +beginMoveRows(parent, 2, 2, parent, 0) +//! [8] + + +//! [9] +beginMoveRows(parent, 2, 2, parent, 4) +//! [9] diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp new file mode 100644 index 000000000..e76808195 --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation 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$ +** +****************************************************************************/ + +//! [simple state machine] +button = QPushButton() + +machine = QStateMachine() +s1 = QState() +s1.assignProperty(button, "text", "Click me") + +s2 = QFinalState() +s1.addTransition(button, SIGNAL('clicked()'), s2) + +machine.addState(s1) +machine.addState(s2) +machine.setInitialState(s1) +machine.start() +//! [simple state machine] |