summaryrefslogtreecommitdiffstats
path: root/src/gui/doc/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/doc/snippets')
-rw-r--r--src/gui/doc/snippets/clipboard/clipwindow.cpp9
-rw-r--r--src/gui/doc/snippets/code/src_gui_accessible_qaccessible.cpp18
-rw-r--r--src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp4
-rw-r--r--src/gui/doc/snippets/code/src_gui_kernel_qguiapplication.cpp9
-rw-r--r--src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp4
-rw-r--r--src/gui/doc/snippets/code/src_gui_math3d_qquaternion.cpp57
-rw-r--r--src/gui/doc/snippets/code/src_gui_opengl_qopenglbuffer.cpp60
-rw-r--r--src/gui/doc/snippets/code/src_gui_opengl_qopengldebug.cpp100
-rw-r--r--src/gui/doc/snippets/code/src_gui_opengl_qopenglfunctions.cpp112
-rw-r--r--src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp28
-rw-r--r--src/gui/doc/snippets/code/src_gui_vulkan_qvulkanfunctions.cpp70
-rw-r--r--src/gui/doc/snippets/code/src_gui_vulkan_qvulkaninstance.cpp146
-rw-r--r--src/gui/doc/snippets/code/src_gui_vulkan_qvulkanwindow.cpp132
-rw-r--r--src/gui/doc/snippets/draganddrop/mainwindow.cpp10
-rw-r--r--src/gui/doc/snippets/picture/picture.cpp10
-rw-r--r--src/gui/doc/snippets/qfontdatabase/main.cpp11
-rw-r--r--src/gui/doc/snippets/qimagewriter/main.cpp71
-rw-r--r--src/gui/doc/snippets/separations/screenwidget.cpp4
-rw-r--r--src/gui/doc/snippets/separations/viewer.cpp18
-rw-r--r--src/gui/doc/snippets/textblock-fragments/mainwindow.cpp8
-rw-r--r--src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp8
-rw-r--r--src/gui/doc/snippets/textdocument-frames/mainwindow.cpp8
-rw-r--r--src/gui/doc/snippets/textdocument-lists/mainwindow.cpp5
-rw-r--r--src/gui/doc/snippets/textdocument-printing/mainwindow.cpp2
-rw-r--r--src/gui/doc/snippets/textdocument-selections/mainwindow.cpp5
-rw-r--r--src/gui/doc/snippets/textdocument-tables/mainwindow.cpp8
26 files changed, 860 insertions, 57 deletions
diff --git a/src/gui/doc/snippets/clipboard/clipwindow.cpp b/src/gui/doc/snippets/clipboard/clipwindow.cpp
index bf1b2d904b..d1b39070fa 100644
--- a/src/gui/doc/snippets/clipboard/clipwindow.cpp
+++ b/src/gui/doc/snippets/clipboard/clipwindow.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "clipwindow.h"
@@ -67,10 +67,11 @@ ClipWindow::ClipWindow(QWidget *parent)
previousItems = new QListWidget(centralWidget);
//! [0]
- connect(clipboard, SIGNAL(dataChanged()), this, SLOT(updateClipboard()));
+ connect(clipboard, &QClipboard::dataChanged,
+ this, &ClipWindow::updateClipboard);
//! [0]
- connect(mimeTypeCombo, SIGNAL(activated(QString)),
- this, SLOT(updateData(QString)));
+ connect(mimeTypeCombo, QOverload<QString>::of(&QComboBox::activated),
+ this, &ClipWindow::updateData);
QVBoxLayout *currentLayout = new QVBoxLayout(currentItem);
currentLayout->addWidget(mimeTypeLabel);
diff --git a/src/gui/doc/snippets/code/src_gui_accessible_qaccessible.cpp b/src/gui/doc/snippets/code/src_gui_accessible_qaccessible.cpp
index 98d40c94f9..2fd76d08c7 100644
--- a/src/gui/doc/snippets/code/src_gui_accessible_qaccessible.cpp
+++ b/src/gui/doc/snippets/code/src_gui_accessible_qaccessible.cpp
@@ -51,3 +51,21 @@
//! [1]
typedef QAccessibleInterface* myFactoryFunction(const QString &key, QObject *);
//! [1]
+
+//! [2]
+void MyWidget::setFocus(Qt::FocusReason reason)
+{
+ // handle custom focus setting...
+ QAccessibleEvent event(f, QAccessible::Focus);
+ QAccessible::updateAccessibility(&event);
+}
+//! [2]
+
+//! [3]
+void *QAccessibleLineEdit::interface_cast(QAccessible::InterfaceType t)
+{
+ if (t == QAccessible::TextInterface)
+ return static_cast<QAccessibleTextInterface*>(this);
+ return QAccessibleWidget::interface_cast(t);
+}
+//! [3]
diff --git a/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp b/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
index 40893fae87..4266da0a11 100644
--- a/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
+++ b/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
@@ -73,8 +73,8 @@ for (int i = 0; i < 4; ++i) {
//! [2]
QTreeView *treeView = new QTreeView(this);
treeView->setModel(myStandardItemModel);
-connect(treeView, SIGNAL(clicked(QModelIndex)),
- this, SLOT(clicked(QModelIndex)));
+connect(treeView, &QTreeView::clicked,
+ this, &MyWidget::clicked);
//! [2]
diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication.cpp
index 7c5c387a5a..a399d444e1 100644
--- a/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication.cpp
+++ b/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication.cpp
@@ -64,7 +64,8 @@ MyMainWidget::MyMainWidget(QWidget *parent)
:QWidget(parent)
{
QGuiApplication::setFallbackSessionManagementEnabled(false);
- connect(qApp, SIGNAL(commitDataRequest(QSessionManager)), SLOT(commitData(QSessionManager)));
+ connect(qApp, &QGuiApplication::commitDataRequest,
+ this, &MyMainWidget::commitData);
}
void MyMainWidget::commitData(QSessionManager& manager)
@@ -102,12 +103,14 @@ appname -session id
//! [3]
-foreach (const QString &command, mySession.restartCommand())
+const QStringList commands = mySession.restartCommand();
+for (const QString &command : commands)
do_something(command);
//! [3]
//! [4]
-foreach (const QString &command, mySession.discardCommand())
+const QStringList commands = mySession.discardCommand();
+for (const QString &command : mySession.discardCommand())
do_something(command);
//! [4]
diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp
index e91aa3d548..961ecd6cde 100644
--- a/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp
+++ b/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp
@@ -49,7 +49,7 @@
****************************************************************************/
//! [0]
-QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
calculateHugeMandelbrot(); // lunch time...
-QApplication::restoreOverrideCursor();
+QGuiApplication::restoreOverrideCursor();
//! [0]
diff --git a/src/gui/doc/snippets/code/src_gui_math3d_qquaternion.cpp b/src/gui/doc/snippets/code/src_gui_math3d_qquaternion.cpp
new file mode 100644
index 0000000000..8da438e3a7
--- /dev/null
+++ b/src/gui/doc/snippets/code/src_gui_math3d_qquaternion.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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]
+ QVector3D result = q.rotatedVector(vector);
+//! [0]
+
+//! [1]
+ QVector3D result = (q * QQuaternion(0, vector) * q.conjugated()).vector();
+//! [1]
diff --git a/src/gui/doc/snippets/code/src_gui_opengl_qopenglbuffer.cpp b/src/gui/doc/snippets/code/src_gui_opengl_qopenglbuffer.cpp
new file mode 100644
index 0000000000..57dc909598
--- /dev/null
+++ b/src/gui/doc/snippets/code/src_gui_opengl_qopenglbuffer.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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]
+ QOpenGLBuffer buffer1(QOpenGLBuffer::IndexBuffer);
+ buffer1.create();
+
+ QOpenGLBuffer buffer2 = buffer1;
+//! [0]
+
+//! [1]
+ QOpenGLBuffer::release(QOpenGLBuffer::VertexBuffer);
+//! [1]
diff --git a/src/gui/doc/snippets/code/src_gui_opengl_qopengldebug.cpp b/src/gui/doc/snippets/code/src_gui_opengl_qopengldebug.cpp
new file mode 100644
index 0000000000..e82447a174
--- /dev/null
+++ b/src/gui/doc/snippets/code/src_gui_opengl_qopengldebug.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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]
+ GLenum error = GL_NO_ERROR;
+ do {
+ error = glGetError();
+ if (error != GL_NO_ERROR)
+ // handle the error
+ } while (error != GL_NO_ERROR);
+//! [0]
+
+//! [1]
+ QSurfaceFormat format;
+ // asks for a OpenGL 3.2 debug context using the Core profile
+ format.setMajorVersion(3);
+ format.setMinorVersion(2);
+ format.setProfile(QSurfaceFormat::CoreProfile);
+ format.setOption(QSurfaceFormat::DebugContext);
+
+ QOpenGLContext *context = new QOpenGLContext;
+ context->setFormat(format);
+ context->create();
+//! [1]
+
+//! [2]
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ QOpenGLDebugLogger *logger = new QOpenGLDebugLogger(this);
+
+ logger->initialize(); // initializes in the current context, i.e. ctx
+//! [2]
+
+//! [3]
+ ctx->hasExtension(QByteArrayLiteral("GL_KHR_debug"))
+//! [3]
+
+//! [4]
+ const QList<QOpenGLDebugMessage> messages = logger->loggedMessages();
+ for (const QOpenGLDebugMessage &message : messages)
+ qDebug() << message;
+//! [4]
+
+//! [5]
+ connect(logger, &QOpenGLDebugLogger::messageLogged, receiver, &LogHandler::handleLoggedMessage);
+ logger->startLogging();
+//! [5]
+
+//! [6]
+ QOpenGLDebugMessage message =
+ QOpenGLDebugMessage::createApplicationMessage(QStringLiteral("Custom message"));
+
+ logger->logMessage(message);
+//! [6]
diff --git a/src/gui/doc/snippets/code/src_gui_opengl_qopenglfunctions.cpp b/src/gui/doc/snippets/code/src_gui_opengl_qopenglfunctions.cpp
new file mode 100644
index 0000000000..e072c110f2
--- /dev/null
+++ b/src/gui/doc/snippets/code/src_gui_opengl_qopenglfunctions.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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]
+ class MyGLWindow : public QWindow, protected QOpenGLFunctions
+ {
+ Q_OBJECT
+ public:
+ MyGLWindow(QScreen *screen = 0);
+
+ protected:
+ void initializeGL();
+ void paintGL();
+
+ QOpenGLContext *m_context;
+ };
+
+ MyGLWindow(QScreen *screen)
+ : QWindow(screen), QOpenGLWidget(parent)
+ {
+ setSurfaceType(OpenGLSurface);
+ create();
+
+ // Create an OpenGL context
+ m_context = new QOpenGLContext;
+ m_context->create();
+
+ // Setup scene and render it
+ initializeGL();
+ paintGL();
+ }
+
+ void MyGLWindow::initializeGL()
+ {
+ m_context->makeCurrent(this);
+ initializeOpenGLFunctions();
+ }
+//! [0]
+
+//! [1]
+ void MyGLWindow::paintGL()
+ {
+ m_context->makeCurrent(this);
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, textureId);
+ ...
+ m_context->swapBuffers(this);
+ m_context->doneCurrent();
+ }
+//! [1]
+
+//! [2]
+ QOpenGLFunctions glFuncs(QOpenGLContext::currentContext());
+ glFuncs.glActiveTexture(GL_TEXTURE1);
+//! [2]
+
+//! [3]
+ QOpenGLFunctions *glFuncs = QOpenGLContext::currentContext()->functions();
+ glFuncs->glActiveTexture(GL_TEXTURE1);
+//! [3]
+
+//! [4]
+ QOpenGLFunctions funcs(QOpenGLContext::currentContext());
+ bool npot = funcs.hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
+//! [4]
diff --git a/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp b/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp
index b48e9e8610..b9a8d8d90e 100644
--- a/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp
+++ b/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp
@@ -68,3 +68,31 @@ mailto:user@foo.com?subject=Test&body=Just a test
//! [2]
QDesktopServices::openUrl(QUrl("file:///C:/Documents and Settings/All Users/Desktop", QUrl::TolerantMode));
//! [2]
+
+//! [3]
+<key>LSApplicationQueriesSchemes</key>
+<array>
+ <string>https</string>
+</array>
+//! [3]
+
+//! [4]
+<key>CFBundleURLTypes</key>
+<array>
+ <dict>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>myapp</string>
+ </array>
+ </dict>
+</array>
+//! [4]
+
+//! [5]
+QDesktopServices::storageLocation(QDesktopServices::DataLocation)
+//! [5]
+
+//! [6]
+QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
+ "/data/organization/application"
+//! [6]
diff --git a/src/gui/doc/snippets/code/src_gui_vulkan_qvulkanfunctions.cpp b/src/gui/doc/snippets/code/src_gui_vulkan_qvulkanfunctions.cpp
new file mode 100644
index 0000000000..0d13873f38
--- /dev/null
+++ b/src/gui/doc/snippets/code/src_gui_vulkan_qvulkanfunctions.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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]
+ void Window::render()
+ {
+ QVulkanInstance *inst = vulkanInstance();
+ QVulkanFunctions *f = inst->functions();
+ ...
+ VkResult err = f->vkAllocateCommandBuffers(device, &cmdBufInfo, &cmdBuf);
+ ...
+ }
+//! [0]
+
+//! [1]
+ void Window::render()
+ {
+ QVulkanInstance *inst = vulkanInstance();
+ QVulkanDeviceFunctions *df = inst->deviceFunctions(device);
+ VkResult err = df->vkAllocateCommandBuffers(device, &cmdBufInfo, &cmdBuf);
+ ...
+ }
+//! [1]
diff --git a/src/gui/doc/snippets/code/src_gui_vulkan_qvulkaninstance.cpp b/src/gui/doc/snippets/code/src_gui_vulkan_qvulkaninstance.cpp
new file mode 100644
index 0000000000..14ef9ed2d4
--- /dev/null
+++ b/src/gui/doc/snippets/code/src_gui_vulkan_qvulkaninstance.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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]
+ int main(int argc, char **argv)
+ {
+ QGuiApplication app(argc, argv);
+
+ QVulkanInstance inst;
+ if (!inst.create())
+ return 1;
+
+ ...
+ window->setVulkanInstance(&inst);
+ window->show();
+
+ return app.exec();
+ }
+//! [0]
+
+//! [1]
+ QVulkanInstance inst;
+
+ // Enable validation layer, if supported. Messages go to qDebug by default.
+ inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
+
+ bool ok = inst.create();
+ if (!ok)
+ ... // Vulkan not available
+ if (!inst.layers().contains("VK_LAYER_LUNARG_standard_validation"))
+ ... // validation layer not available
+//! [1]
+
+//! [2]
+ QVulkanInstance inst;
+
+ if (inst.supportedLayers().contains("VK_LAYER_LUNARG_standard_validation"))
+ ...
+
+ bool ok = inst.create();
+ ...
+//! [2]
+
+//! [3]
+ class VulkanWindow : public QWindow
+ {
+ public:
+ VulkanWindow() {
+ setSurfaceType(VulkanSurface);
+ }
+
+ void exposeEvent(QExposeEvent *) {
+ if (isExposed()) {
+ if (!m_initialized) {
+ m_initialized = true;
+ // initialize device, swapchain, etc.
+ QVulkanInstance *inst = vulkanInstance();
+ QVulkanFunctions *f = inst->functions();
+ uint32_t devCount = 0;
+ f->vkEnumeratePhysicalDevices(inst->vkInstance(), &devCount, nullptr);
+ ...
+ // build the first frame
+ render();
+ }
+ }
+ }
+
+ bool event(QEvent *e) {
+ if (e->type() == QEvent::UpdateRequest)
+ render();
+ return QWindow::event(e);
+ }
+
+ void render() {
+ ...
+ requestUpdate(); // render continuously
+ }
+
+ private:
+ bool m_initialized = false;
+ };
+
+ int main(int argc, char **argv)
+ {
+ QGuiApplication app(argc, argv);
+
+ QVulkanInstance inst;
+ if (!inst.create()) {
+ qWarning("Vulkan not available");
+ return 1;
+ }
+
+ VulkanWindow window;
+ window.showMaximized();
+
+ return app.exec();
+
+ }
+//! [3]
diff --git a/src/gui/doc/snippets/code/src_gui_vulkan_qvulkanwindow.cpp b/src/gui/doc/snippets/code/src_gui_vulkan_qvulkanwindow.cpp
new file mode 100644
index 0000000000..81d51233a3
--- /dev/null
+++ b/src/gui/doc/snippets/code/src_gui_vulkan_qvulkanwindow.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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]
+ class VulkanRenderer : public QVulkanWindowRenderer
+ {
+ public:
+ VulkanRenderer(QVulkanWindow *w) : m_window(w) { }
+
+ void initResources() override
+ {
+ m_devFuncs = m_window->vulkanInstance()->deviceFunctions(m_window->device());
+ ...
+ }
+ void initSwapChainResources() override { ... }
+ void releaseSwapChainResources() override { ... }
+ void releaseResources() override { ... }
+
+ void startNextFrame() override
+ {
+ VkCommandBuffer cmdBuf = m_window->currentCommandBuffer();
+ ...
+ m_devFuncs->vkCmdBeginRenderPass(...);
+ ...
+ m_window->frameReady();
+ }
+
+ private:
+ QVulkanWindow *m_window;
+ QVulkanDeviceFunctions *m_devFuncs;
+ };
+
+ class VulkanWindow : public QVulkanWindow
+ {
+ public:
+ QVulkanWindowRenderer *createRenderer() override {
+ return new VulkanRenderer(this);
+ }
+ };
+
+ int main(int argc, char *argv[])
+ {
+ QGuiApplication app(argc, argv);
+
+ QVulkanInstance inst;
+ // enable the standard validation layers, when available
+ inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
+ if (!inst.create())
+ qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
+
+ VulkanWindow w;
+ w.setVulkanInstance(&inst);
+ w.showMaximized();
+
+ return app.exec();
+ }
+//! [0]
+
+//! [1]
+ class Renderer {
+ ...
+ VkDescriptorBufferInfo m_uniformBufInfo[QVulkanWindow::MAX_CONCURRENT_FRAME_COUNT];
+ };
+
+ void Renderer::startNextFrame()
+ {
+ VkDescriptorBufferInfo &uniformBufInfo(m_uniformBufInfo[m_window->currentFrame()]);
+ ...
+ }
+//! [1]
+
+//! [2]
+ class Renderer {
+ ...
+ VkDescriptorBufferInfo m_uniformBufInfo[QVulkanWindow::MAX_CONCURRENT_FRAME_COUNT];
+ };
+
+ void Renderer::startNextFrame()
+ {
+ const int count = m_window->concurrentFrameCount();
+ for (int i = 0; i < count; ++i)
+ m_uniformBufInfo[i] = ...
+ ...
+ }
+//! [2]
diff --git a/src/gui/doc/snippets/draganddrop/mainwindow.cpp b/src/gui/doc/snippets/draganddrop/mainwindow.cpp
index 551114856e..11311a0b57 100644
--- a/src/gui/doc/snippets/draganddrop/mainwindow.cpp
+++ b/src/gui/doc/snippets/draganddrop/mainwindow.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "dragwidget.h"
#include "mainwindow.h"
@@ -64,10 +64,10 @@ MainWindow::MainWindow(QWidget *parent)
QLabel *dataLabel = new QLabel(tr("Amount of data (bytes):"), centralWidget);
dragWidget = new DragWidget(centralWidget);
- connect(dragWidget, SIGNAL(mimeTypes(QStringList)),
- this, SLOT(setMimeTypes(QStringList)));
- connect(dragWidget, SIGNAL(dragResult(QString)),
- this, SLOT(setDragResult(QString)));
+ connect(dragWidget, &DragWidget::mimeTypes,
+ this, &MainWindow::setMimeTypes);
+ connect(dragWidget, &DragWidget:dragResult,
+ this, &MainWindow::setDragResult);
QVBoxLayout *mainLayout = new QVBoxLayout(centralWidget);
mainLayout->addWidget(mimeTypeLabel);
diff --git a/src/gui/doc/snippets/picture/picture.cpp b/src/gui/doc/snippets/picture/picture.cpp
index 3a7676f60a..863476fdbf 100644
--- a/src/gui/doc/snippets/picture/picture.cpp
+++ b/src/gui/doc/snippets/picture/picture.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
void myProcessing(const QString &)
{
@@ -85,8 +85,8 @@ int main()
{
// FORMATS
//! [2]
- QStringList list = QPicture::inputFormatList();
- foreach (const QString &string, list)
+ const QStringList list = QPicture::inputFormatList();
+ for (const QString &string : list)
myProcessing(string);
//! [2]
}
@@ -94,8 +94,8 @@ int main()
{
// OUTPUT
//! [3]
- QStringList list = QPicture::outputFormatList();
- foreach (const QString &string, list)
+ const QStringList list = QPicture::outputFormatList();
+ for (const QString &string : list)
myProcessing(string);
//! [3]
}
diff --git a/src/gui/doc/snippets/qfontdatabase/main.cpp b/src/gui/doc/snippets/qfontdatabase/main.cpp
index ae078f374d..5a5aa7b485 100644
--- a/src/gui/doc/snippets/qfontdatabase/main.cpp
+++ b/src/gui/doc/snippets/qfontdatabase/main.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
int main(int argc, char **argv)
{
@@ -60,16 +60,19 @@ int main(int argc, char **argv)
fontTree.setColumnCount(2);
fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes");
- foreach (const QString &family, database.families()) {
+ const QStringList fontFamilies = database.families();
+ for (const QString &family : fontFamilies) {
QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree);
familyItem->setText(0, family);
- foreach (const QString &style, database.styles(family)) {
+ const QStringList fontStyles = database.styles(family);
+ for (const QString &style : fontStyles) {
QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
styleItem->setText(0, style);
QString sizes;
- foreach (int points, database.smoothSizes(family, style))
+ const QList<int> smoothSizes = database.smoothSizes(family, style)
+ for (int points : smoothSizes)
sizes += QString::number(points) + ' ';
styleItem->setText(1, sizes.trimmed());
diff --git a/src/gui/doc/snippets/qimagewriter/main.cpp b/src/gui/doc/snippets/qimagewriter/main.cpp
new file mode 100644
index 0000000000..3758110356
--- /dev/null
+++ b/src/gui/doc/snippets/qimagewriter/main.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Samuel Gaist <samuel.gaist@idiap.ch>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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 <QtGui>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QString imagePath(QStringLiteral("path/image.jpeg"));
+ QImage image(64, 64, QImage::Format_RGB32);
+ image.fill(Qt::red);
+ {
+ QImageWriter writer(imagePath);
+ writer.write(image);
+ }
+
+ QFile::rename(imagePath,
+ QStringLiteral("path/other_image.jpeg"));
+//! [0]
+
+ return 0;
+}
diff --git a/src/gui/doc/snippets/separations/screenwidget.cpp b/src/gui/doc/snippets/separations/screenwidget.cpp
index 6f8be49bfa..d562991d26 100644
--- a/src/gui/doc/snippets/separations/screenwidget.cpp
+++ b/src/gui/doc/snippets/separations/screenwidget.cpp
@@ -105,8 +105,8 @@ ScreenWidget::ScreenWidget(QWidget *parent, QColor initialColor,
//invertButton->setOn(inverted);
invertButton->setEnabled(false);
- connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
- connect(invertButton, SIGNAL(clicked()), this, SLOT(invertImage()));
+ connect(colorButton, &QPushButton::clicked, this, &ScreenWidget::setColor);
+ connect(invertButton, &QPushButton::clicked, this, &ScreenWidget::invertImage);
QGridLayout *gridLayout = new QGridLayout;
gridLayout->addWidget(imageLabel, 0, 0, 1, 2);
diff --git a/src/gui/doc/snippets/separations/viewer.cpp b/src/gui/doc/snippets/separations/viewer.cpp
index 641294ea35..018b397f1a 100644
--- a/src/gui/doc/snippets/separations/viewer.cpp
+++ b/src/gui/doc/snippets/separations/viewer.cpp
@@ -58,7 +58,7 @@ A main menu provides entries for selecting files, and adjusting the
brightness of the separations.
*/
-#include <QtGui>
+#include <QtWidgets>
#include "finalwidget.h"
#include "screenwidget.h"
@@ -126,11 +126,11 @@ void Viewer::createMenus()
menuBar()->addMenu(fileMenu);
menuBar()->addMenu(brightnessMenu);
- connect(openAction, SIGNAL(triggered()), this, SLOT(chooseFile()));
- connect(saveAction, SIGNAL(triggered()), this, SLOT(saveImage()));
- connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
- connect(brightnessMenu, SIGNAL(triggered(QAction*)), this,
- SLOT(setBrightness(QAction*)));
+ connect(openAction, &QAction::triggered, this, &Viewer::chooseFile);
+ connect(saveAction, &QAction::triggered, this, &Viewer::saveImage);
+ connect(quitAction, &QAction::triggered, qApp, QApplication::quit);
+ connect(brightnessMenu, &QMenu::triggered,
+ this, &Viewer::setBrightness);
}
/*
@@ -160,9 +160,9 @@ QFrame* Viewer::createCentralWidget()
yellowWidget = new ScreenWidget(frame, Qt::yellow, tr("Yellow"),
ScreenWidget::Yellow, labelSize);
- connect(cyanWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
- connect(magentaWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
- connect(yellowWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+ connect(cyanWidget, &ScreenWidget::imageChanged, this, &Viewer::createImage);
+ connect(magentaWidget, &ScreenWidget::imageChanged, this, &Viewer::createImage);
+ connect(yellowWidget, &ScreenWidget::imageChanged, this, &Viewer::createImage);
grid->addWidget(finalWidget, 0, 0, Qt::AlignTop | Qt::AlignHCenter);
grid->addWidget(cyanWidget, 0, 1, Qt::AlignTop | Qt::AlignHCenter);
diff --git a/src/gui/doc/snippets/textblock-fragments/mainwindow.cpp b/src/gui/doc/snippets/textblock-fragments/mainwindow.cpp
index bcc5c7dc30..bf864ce48d 100644
--- a/src/gui/doc/snippets/textblock-fragments/mainwindow.cpp
+++ b/src/gui/doc/snippets/textblock-fragments/mainwindow.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "xmlwriter.h"
@@ -73,9 +73,9 @@ MainWindow::MainWindow()
editor = new QTextEdit(this);
- connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
- connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
- connect(calendarAction, SIGNAL(triggered()), this, SLOT(insertCalendar()));
+ connect(saveAction, &QAction::triggered, this, &MainWindow::saveFile);
+ connect(quitAction, &QAction::triggered, this, &MainWindow::close);
+ connect(calendarAction, &QAction::triggered, this, &MainWindow::insertCalendar);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Writer"));
diff --git a/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp b/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp
index f512cf0dc6..a5801da67e 100644
--- a/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp
+++ b/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "xmlwriter.h"
@@ -75,9 +75,9 @@ MainWindow::MainWindow()
editor = new QTextEdit(this);
//! [0]
- connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
- connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
- connect(calendarAction, SIGNAL(triggered()), this, SLOT(insertCalendar()));
+ connect(saveAction, &QAction::triggered, this, &MainWindow::saveFile);
+ connect(quitAction, &QAction::triggered, this, &MainWindow::close);
+ connect(calendarAction, &QAction::triggered, this, &MainWindow::insertCalendar);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Writer"));
diff --git a/src/gui/doc/snippets/textdocument-frames/mainwindow.cpp b/src/gui/doc/snippets/textdocument-frames/mainwindow.cpp
index f15ad45f2e..edfadb4c77 100644
--- a/src/gui/doc/snippets/textdocument-frames/mainwindow.cpp
+++ b/src/gui/doc/snippets/textdocument-frames/mainwindow.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "xmlwriter.h"
@@ -64,7 +64,7 @@ MainWindow::MainWindow()
quitAction->setShortcut(tr("Ctrl+Q"));
menuBar()->addMenu(fileMenu);
- editor = new QTextEdit();
+ editor = new QTextEdit;
QTextCursor cursor(editor->textCursor());
cursor.movePosition(QTextCursor::Start);
@@ -130,8 +130,8 @@ MainWindow::MainWindow()
plainCharFormat);
- connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
- connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(saveAction, &QAction::triggered, this, &MainWindow::saveFile);
+ connect(quitAction, &QAction::triggered, this, &MainWindow::close);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Frames"));
diff --git a/src/gui/doc/snippets/textdocument-lists/mainwindow.cpp b/src/gui/doc/snippets/textdocument-lists/mainwindow.cpp
index 15a2752c8b..785f7ebcc9 100644
--- a/src/gui/doc/snippets/textdocument-lists/mainwindow.cpp
+++ b/src/gui/doc/snippets/textdocument-lists/mainwindow.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
@@ -88,7 +88,8 @@ MainWindow::MainWindow()
document = new QTextDocument(this);
editor->setDocument(document);
- connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+ connect(editor, &QTextEdit::selectionChanged,
+ this, &MainWindow::updateMenus);
updateMenus();
diff --git a/src/gui/doc/snippets/textdocument-printing/mainwindow.cpp b/src/gui/doc/snippets/textdocument-printing/mainwindow.cpp
index 40459b49da..a7bd90a9f1 100644
--- a/src/gui/doc/snippets/textdocument-printing/mainwindow.cpp
+++ b/src/gui/doc/snippets/textdocument-printing/mainwindow.cpp
@@ -74,7 +74,7 @@ MainWindow::MainWindow()
document = new QTextDocument(this);
editor->setDocument(document);
- connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+ connect(editor, &QTextEdit::selectionChanged, this, &MainWindow::updateMenus);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Writer"));
diff --git a/src/gui/doc/snippets/textdocument-selections/mainwindow.cpp b/src/gui/doc/snippets/textdocument-selections/mainwindow.cpp
index 8ac3913f3c..9253e87670 100644
--- a/src/gui/doc/snippets/textdocument-selections/mainwindow.cpp
+++ b/src/gui/doc/snippets/textdocument-selections/mainwindow.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
@@ -90,7 +90,8 @@ MainWindow::MainWindow()
document = new QTextDocument(this);
editor->setDocument(document);
- connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+ connect(editor, &QTextEdit::selectionChanged,
+ this, &MainWindow::updateMenus);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Writer"));
diff --git a/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp b/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp
index 061c191f1c..bd976a8ce4 100644
--- a/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp
+++ b/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp
@@ -48,7 +48,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "xmlwriter.h"
@@ -132,9 +132,9 @@ MainWindow::MainWindow()
}
//! [8]
- connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
- connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
- connect(showTableAction, SIGNAL(triggered()), this, SLOT(showTable()));
+ connect(saveAction, &QAction:triggered, this, &MainWindow::saveFile);
+ connect(quitAction, &QAction:triggered, this, &MainWindow::close);
+ connect(showTableAction, &QAction:triggered, this, &MainWindow::showTable);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Tables"));