summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp2
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp2
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qworkspace.cpp48
-rw-r--r--doc/src/snippets/qstring/main.cpp65
-rw-r--r--doc/src/snippets/qstringlist/main.cpp15
5 files changed, 80 insertions, 52 deletions
diff --git a/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp b/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp
index afba3b6a61..7c0c2c2122 100644
--- a/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp
+++ b/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp
@@ -107,7 +107,7 @@ for(int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i)
const QMetaObject* metaObject = obj->metaObject();
QStringList methods;
for(int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i)
- methods << QString::fromLatin1(metaObject->method(i).signature());
+ methods << QString::fromLatin1(metaObject->method(i).methodSignature());
//! [methodCount]
//! [6]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
index 9d72c42504..d0a7a69884 100644
--- a/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
+++ b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
@@ -73,7 +73,7 @@ MyStruct s2 = var.value<MyStruct>();
//! [3]
int id = QMetaType::type("MyClass");
-if (id != 0) {
+if (id != QMetaType::UnknownType) {
void *myClassPtr = QMetaType::create(id);
...
QMetaType::destroy(id, myClassPtr);
diff --git a/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp b/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp
deleted file mode 100644
index a809786738..0000000000
--- a/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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$
-**
-****************************************************************************/
-
-//! [0]
-MainWindow::MainWindow()
-{
- workspace = new QWorkspace;
- setCentralWidget(workspace);
- ...
-}
-//! [0]
diff --git a/doc/src/snippets/qstring/main.cpp b/doc/src/snippets/qstring/main.cpp
index d0a445731c..d7299e80d5 100644
--- a/doc/src/snippets/qstring/main.cpp
+++ b/doc/src/snippets/qstring/main.cpp
@@ -314,6 +314,11 @@ void Widget::countFunction()
QString str = "banana and panama";
str.count(QRegExp("a[nm]a")); // returns 4
//! [18]
+
+ //! [95]
+ QString str = "banana and panama";
+ str.count(QRegularExpression("a[nm]a")); // returns 4
+ //! [95]
}
void Widget::dataFunction()
@@ -384,6 +389,11 @@ void Widget::firstIndexOfFunction()
QString str = "the minimum";
str.indexOf(QRegExp("m[aeiou]"), 0); // returns 4
//! [25]
+
+ //! [93]
+ QString str = "the minimum";
+ str.indexOf(QRegularExpression("m[aeiou]"), 0); // returns 4
+ //! [93]
}
void Widget::insertFunction()
@@ -429,6 +439,11 @@ void Widget::lastIndexOfFunction()
QString str = "the minimum";
str.lastIndexOf(QRegExp("m[aeiou]")); // returns 8
//! [30]
+
+ //! [94]
+ QString str = "the minimum";
+ str.lastIndexOf(QRegularExpression("m[aeiou]")); // returns 8
+ //! [94]
}
void Widget::leftFunction()
@@ -499,6 +514,12 @@ void Widget::removeFunction()
r.remove(QRegExp("[aeiou]."));
// r == "The"
//! [39]
+
+ //! [96]
+ QString r = "Telephone";
+ r.remove(QRegularExpression("[aeiou]."));
+ // r == "The"
+ //! [96]
}
void Widget::replaceFunction()
@@ -533,6 +554,18 @@ void Widget::replaceFunction()
equis.replace("xx", "x");
// equis == "xxx"
//! [86]
+
+ //! [87]
+ QString s = "Banana";
+ s.replace(QRegularExpression("a[mn]"), "ox");
+ // s == "Boxoxa"
+ //! [87]
+
+ //! [88]
+ QString t = "A <i>bon mot</i>.";
+ t.replace(QRegularExpression("<i>([^<]*)</i>"), "\\emph{\\1}");
+ // t == "A \\emph{bon mot}."
+ //! [88]
}
void Widget::reserveFunction()
@@ -627,9 +660,16 @@ void Widget::sectionFunction()
//! [55]
QString line = "forename\tmiddlename surname \t \t phone";
QRegExp sep("\\s+");
- str = line.section(sep, 2, 2); // s == "surname"
- str = line.section(sep, -3, -2); // s == "middlename surname"
+ str = line.section(sep, 2, 2); // str == "surname"
+ str = line.section(sep, -3, -2); // str == "middlename surname"
//! [55]
+
+ //! [89]
+ QString line = "forename\tmiddlename surname \t \t phone";
+ QRegularExpression sep("\\s+");
+ str = line.section(sep, 2, 2); // str == "surname"
+ str = line.section(sep, -3, -2); // str == "middlename surname"
+ //! [89]
}
void Widget::setNumFunction()
@@ -682,6 +722,27 @@ void Widget::splitFunction()
list = str.split(QRegExp("\\b"));
// list: [ "", "Now", ": ", "this", " ", "sentence", " ", "fragment", "." ]
//! [61]
+
+ //! [90]
+ QString str;
+ QStringList list;
+
+ str = "Some text\n\twith strange whitespace.";
+ list = str.split(QRegularExpression("\\s+"));
+ // list: [ "Some", "text", "with", "strange", "whitespace." ]
+ //! [90]
+
+ //! [91]
+ str = "This time, a normal English sentence.";
+ list = str.split(QRegularExpression("\\W+"), QString::SkipEmptyParts);
+ // list: [ "This", "time", "a", "normal", "English", "sentence" ]
+ //! [91]
+
+ //! [92]
+ str = "Now: this sentence fragment.";
+ list = str.split(QRegularExpression("\\b"));
+ // list: [ "", "Now", ": ", "this", " ", "sentence", " ", "fragment", "." ]
+ //! [92]
}
void Widget::splitCaseSensitiveFunction()
diff --git a/doc/src/snippets/qstringlist/main.cpp b/doc/src/snippets/qstringlist/main.cpp
index d2d2afc281..8ca463371e 100644
--- a/doc/src/snippets/qstringlist/main.cpp
+++ b/doc/src/snippets/qstringlist/main.cpp
@@ -144,6 +144,21 @@ Widget::Widget(QWidget *parent)
list.replaceInStrings(QRegExp("^(.*), (.*)$"), "\\2 \\1");
// list == ["Bill Clinton", "Bill Murray"]
//! [15]
+
+ list.clear();
+//! [16]
+ list << "alpha" << "beta" << "gamma" << "epsilon";
+ list.replaceInStrings(QRegularExpression("^a"), "o");
+ // list == ["olpha", "beta", "gamma", "epsilon"]
+//! [16]
+
+ list.clear();
+//! [17]
+ list << "Bill Clinton" << "Murray, Bill";
+ list.replaceInStrings(QRegularExpression("^(.*), (.*)$"), "\\2 \\1");
+ // list == ["Bill Clinton", "Bill Murray"]
+//! [17]
+
}
int main(int argc, char *argv[])