summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/corelib/ipc/localfortuneclient/client.cpp3
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp4
-rw-r--r--examples/corelib/serialization/convert/cborconverter.cpp6
-rw-r--r--examples/corelib/serialization/convert/datastreamconverter.cpp8
-rw-r--r--examples/corelib/serialization/convert/jsonconverter.cpp60
-rw-r--r--examples/corelib/serialization/convert/jsonconverter.h13
-rw-r--r--examples/corelib/serialization/convert/textconverter.cpp6
-rw-r--r--examples/corelib/serialization/convert/xmlconverter.cpp26
-rw-r--r--examples/corelib/serialization/savegame/doc/src/savegame.qdoc8
-rw-r--r--examples/corelib/serialization/savegame/game.cpp11
-rw-r--r--examples/corelib/threads/doc/src/mandelbrot.qdoc25
-rw-r--r--examples/corelib/threads/mandelbrot/main.cpp2
-rw-r--r--examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp54
-rw-r--r--examples/corelib/threads/mandelbrot/renderthread.cpp35
-rw-r--r--examples/corelib/threads/mandelbrot/renderthread.h10
-rw-r--r--examples/corelib/tools/customtype/main.cpp2
-rw-r--r--examples/corelib/tools/customtype/message.cpp2
-rw-r--r--examples/embedded/flickable/flickable.cpp10
-rw-r--r--examples/embedded/lightmaps/mapzoom.cpp43
-rw-r--r--examples/embedded/lightmaps/mapzoom.h3
-rw-r--r--examples/embedded/raycasting/raycasting.cpp8
-rw-r--r--examples/gui/openglwindow/main.cpp49
-rw-r--r--examples/gui/openglwindow/openglwindow.cpp11
-rw-r--r--examples/gui/openglwindow/openglwindow.h12
-rw-r--r--examples/network/bearermonitor/bearermonitor.cpp424
-rw-r--r--examples/network/bearermonitor/bearermonitor.h96
-rw-r--r--examples/network/bearermonitor/bearermonitor.pro22
-rw-r--r--examples/network/bearermonitor/bearermonitor_240_320.ui420
-rw-r--r--examples/network/bearermonitor/bearermonitor_640_480.ui386
-rw-r--r--examples/network/bearermonitor/main.cpp69
-rw-r--r--examples/network/bearermonitor/sessionwidget.cpp203
-rw-r--r--examples/network/bearermonitor/sessionwidget.h88
-rw-r--r--examples/network/bearermonitor/sessionwidget.ui307
-rw-r--r--examples/network/blockingfortuneclient/blockingclient.cpp39
-rw-r--r--examples/network/blockingfortuneclient/blockingclient.h2
-rw-r--r--examples/network/blockingfortuneclient/fortunethread.h2
-rw-r--r--examples/network/broadcastreceiver/receiver.cpp13
-rw-r--r--examples/network/dnslookup/dnslookup.cpp4
-rw-r--r--examples/network/doc/src/blockingfortuneclient.qdoc7
-rw-r--r--examples/network/doc/src/fortuneclient.qdoc6
-rw-r--r--examples/network/download/main.cpp8
-rw-r--r--examples/network/downloadmanager/downloadmanager.cpp16
-rw-r--r--examples/network/downloadmanager/main.cpp3
-rw-r--r--examples/network/fortuneclient/client.cpp50
-rw-r--r--examples/network/fortuneclient/client.h4
-rw-r--r--examples/network/fortuneserver/server.cpp41
-rw-r--r--examples/network/fortuneserver/server.h5
-rw-r--r--examples/network/googlesuggest/googlesuggest.cpp16
-rw-r--r--examples/network/googlesuggest/searchbox.cpp8
-rw-r--r--examples/network/http/http.pro4
-rw-r--r--examples/network/http/main.cpp27
-rw-r--r--examples/network/loopback/dialog.cpp5
-rw-r--r--examples/network/multicastreceiver/receiver.cpp10
-rw-r--r--examples/network/multistreamclient/client.cpp3
-rw-r--r--examples/network/network-chat/chatdialog.cpp16
-rw-r--r--examples/network/network-chat/chatdialog.h2
-rw-r--r--examples/network/network-chat/client.cpp19
-rw-r--r--examples/network/network-chat/connection.cpp13
-rw-r--r--examples/network/network-chat/connection.h4
-rw-r--r--examples/network/network-chat/main.cpp39
-rw-r--r--examples/network/network-chat/peermanager.cpp8
-rw-r--r--examples/network/network-chat/server.h2
-rw-r--r--examples/network/network.pro14
-rw-r--r--examples/network/securesocketclient/main.cpp4
-rw-r--r--examples/network/securesocketclient/sslclient.cpp37
-rw-r--r--examples/network/threadedfortuneserver/dialog.cpp2
-rw-r--r--examples/network/threadedfortuneserver/dialog.h2
-rw-r--r--examples/network/threadedfortuneserver/fortuneserver.cpp2
-rw-r--r--examples/network/threadedfortuneserver/fortuneserver.h2
-rw-r--r--examples/network/torrent/addtorrentdialog.cpp12
-rw-r--r--examples/network/torrent/addtorrentdialog.h2
-rw-r--r--examples/network/torrent/filemanager.h2
-rw-r--r--examples/network/torrent/mainwindow.cpp94
-rw-r--r--examples/network/torrent/mainwindow.h2
-rw-r--r--examples/network/torrent/peerwireclient.cpp34
-rw-r--r--examples/network/torrent/peerwireclient.h2
-rw-r--r--examples/network/torrent/ratecontroller.cpp6
-rw-r--r--examples/network/torrent/ratecontroller.h9
-rw-r--r--examples/network/torrent/torrentclient.cpp88
-rw-r--r--examples/network/torrent/torrentclient.h5
-rw-r--r--examples/network/torrent/torrentserver.cpp10
-rw-r--r--examples/network/torrent/trackerclient.cpp16
-rw-r--r--examples/network/torrent/trackerclient.h16
-rw-r--r--examples/opengl/computegles31/glwindow.cpp39
-rw-r--r--examples/opengl/computegles31/glwindow.h22
-rw-r--r--examples/opengl/contextinfo/renderwindow.cpp4
-rw-r--r--examples/opengl/contextinfo/widget.h2
-rw-r--r--examples/opengl/cube/geometryengine.cpp2
-rw-r--r--examples/opengl/cube/mainwidget.cpp10
-rw-r--r--examples/opengl/cube/mainwidget.h8
-rw-r--r--examples/opengl/doc/src/2dpainting.qdoc20
-rw-r--r--examples/opengl/doc/src/cube.qdoc4
-rw-r--r--examples/opengl/hellogl2/glwidget.cpp14
-rw-r--r--examples/opengl/hellogl2/glwidget.h18
-rw-r--r--examples/opengl/hellogl2/logo.cpp1
-rw-r--r--examples/opengl/hellogl2/logo.h2
-rw-r--r--examples/opengl/hellogl2/mainwindow.cpp3
-rw-r--r--examples/opengl/hellogl2/window.cpp8
-rw-r--r--examples/opengl/hellogles3/glwindow.cpp32
-rw-r--r--examples/opengl/hellogles3/glwindow.h26
-rw-r--r--examples/opengl/paintedwindow/paintedwindow.cpp1
-rw-r--r--examples/opengl/qopenglwidget/bubble.cpp7
-rw-r--r--examples/opengl/qopenglwidget/bubble.h2
-rw-r--r--examples/opengl/qopenglwidget/glwidget.cpp8
-rw-r--r--examples/opengl/qopenglwidget/glwidget.h46
-rw-r--r--examples/opengl/qopenglwindow/main.cpp1
-rw-r--r--examples/opengl/textures/glwidget.cpp11
-rw-r--r--examples/opengl/textures/glwidget.h14
-rw-r--r--examples/opengl/threadedqopenglwidget/glwidget.cpp7
-rw-r--r--examples/opengl/threadedqopenglwidget/glwidget.h18
-rw-r--r--examples/qpa/qrasterwindow/main.cpp1
-rw-r--r--examples/sql/doc/src/drilldown.qdoc5
-rw-r--r--examples/sql/drilldown/imageitem.h3
-rw-r--r--examples/sql/masterdetail/dialog.cpp2
-rw-r--r--examples/sql/masterdetail/mainwindow.cpp2
-rw-r--r--examples/widgets/animation/easing/window.cpp7
-rw-r--r--examples/widgets/animation/easing/window.h2
-rw-r--r--examples/widgets/desktop/screenshot/screenshot.cpp2
-rw-r--r--examples/widgets/desktop/systray/window.cpp2
-rw-r--r--examples/widgets/dialogs/standarddialogs/dialog.cpp5
-rw-r--r--examples/widgets/doc/dropsite.qdoc12
-rw-r--r--examples/widgets/doc/src/gallery.qdoc (renamed from examples/xml/saxbookmarks/doc/src/saxbookmarks.qdoc)19
-rw-r--r--examples/widgets/doc/src/icons.qdoc38
-rw-r--r--examples/widgets/doc/src/imageviewer.qdoc4
-rw-r--r--examples/widgets/doc/src/padnavigator.qdoc2
-rw-r--r--examples/widgets/doc/src/styles.qdoc1
-rw-r--r--examples/widgets/draganddrop/draggableicons/dragwidget.cpp2
-rw-r--r--examples/widgets/draganddrop/draggabletext/dragwidget.cpp2
-rw-r--r--examples/widgets/draganddrop/dropsite/dropsitewindow.cpp21
-rw-r--r--examples/widgets/draganddrop/dropsite/dropsitewindow.h2
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp6
-rw-r--r--examples/widgets/gallery/gallery.pro10
-rw-r--r--examples/widgets/gallery/main.cpp (renamed from examples/xml/saxbookmarks/main.cpp)25
-rw-r--r--examples/widgets/gallery/widgetgallery.cpp474
-rw-r--r--examples/widgets/gallery/widgetgallery.h (renamed from examples/xml/saxbookmarks/mainwindow.h)44
-rw-r--r--examples/widgets/graphicsview/boxes/scene.h1
-rw-r--r--examples/widgets/graphicsview/chip/view.cpp4
-rw-r--r--examples/widgets/graphicsview/collidingmice/main.cpp3
-rw-r--r--examples/widgets/graphicsview/diagramscene/main.cpp3
-rw-r--r--examples/widgets/graphicsview/diagramscene/mainwindow.cpp17
-rw-r--r--examples/widgets/graphicsview/diagramscene/mainwindow.h4
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/customproxy.h2
-rw-r--r--examples/widgets/graphicsview/flowlayout/window.cpp2
-rw-r--r--examples/widgets/itemviews/addressbook/main.cpp3
-rw-r--r--examples/widgets/itemviews/chart/mainwindow.cpp2
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/window.cpp2
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp2
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treemodel.cpp3
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treemodel.cpp3
-rw-r--r--examples/widgets/itemviews/spreadsheet/main.cpp4
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp2
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h4
-rw-r--r--examples/widgets/layouts/basiclayouts/main.cpp4
-rw-r--r--examples/widgets/layouts/dynamiclayouts/main.cpp5
-rw-r--r--examples/widgets/layouts/flowlayout/flowlayout.cpp2
-rw-r--r--examples/widgets/mainwindows/application/main.cpp3
-rw-r--r--examples/widgets/mainwindows/dockwidgets/main.cpp3
-rw-r--r--examples/widgets/mainwindows/mainwindow/colorswatch.h2
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.cpp4
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.h2
-rw-r--r--examples/widgets/painting/affine/main.cpp4
-rw-r--r--examples/widgets/painting/affine/xform.cpp26
-rw-r--r--examples/widgets/painting/basicdrawing/renderarea.cpp1
-rw-r--r--examples/widgets/painting/concentriccircles/main.cpp3
-rw-r--r--examples/widgets/painting/deform/pathdeform.cpp2
-rw-r--r--examples/widgets/painting/fontsampler/main.cpp3
-rw-r--r--examples/widgets/painting/gradients/gradients.cpp23
-rw-r--r--examples/widgets/painting/gradients/main.cpp3
-rw-r--r--examples/widgets/painting/pathstroke/main.cpp3
-rw-r--r--examples/widgets/painting/pathstroke/pathstroke.cpp4
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp2
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.cpp2
-rw-r--r--examples/widgets/tools/settingseditor/mainwindow.cpp4
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.cpp2
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.cpp132
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.h2
-rw-r--r--examples/widgets/tools/undo/main.cpp3
-rw-r--r--examples/widgets/tutorials/addressbook/part7/addressbook.cpp2
-rw-r--r--examples/widgets/widgets.pro1
-rw-r--r--examples/widgets/widgets/calculator/main.cpp3
-rw-r--r--examples/widgets/widgets/charactermap/mainwindow.cpp2
-rw-r--r--examples/widgets/widgets/elidedlabel/main.cpp3
-rw-r--r--examples/widgets/widgets/icons/imagedelegate.cpp5
-rw-r--r--examples/widgets/widgets/icons/imagedelegate.h6
-rw-r--r--examples/widgets/widgets/icons/mainwindow.cpp28
-rw-r--r--examples/widgets/widgets/imageviewer/imageviewer.cpp12
-rw-r--r--examples/widgets/widgets/scribble/main.cpp3
-rw-r--r--examples/widgets/widgets/sliders/main.cpp3
-rw-r--r--examples/widgets/widgets/styles/norwegianwoodstyle.cpp1
-rw-r--r--examples/widgets/widgets/styles/widgetgallery.cpp8
-rw-r--r--examples/widgets/widgets/styles/widgetgallery.h2
-rw-r--r--examples/widgets/widgets/tablet/mainwindow.cpp6
-rw-r--r--examples/widgets/widgets/tablet/tabletcanvas.cpp8
-rw-r--r--examples/widgets/widgets/validators/localeselector.cpp2
-rw-r--r--examples/xml/dombookmarks/xbeltree.cpp2
-rw-r--r--examples/xml/rsslisting/rsslisting.cpp2
-rw-r--r--examples/xml/saxbookmarks/doc/images/saxbookmarks-example.pngbin26219 -> 0 bytes
-rw-r--r--examples/xml/saxbookmarks/jennifer.xbel69
-rw-r--r--examples/xml/saxbookmarks/mainwindow.cpp177
-rw-r--r--examples/xml/saxbookmarks/saxbookmarks.pro15
-rw-r--r--examples/xml/saxbookmarks/xbelgenerator.cpp124
-rw-r--r--examples/xml/saxbookmarks/xbelgenerator.h78
-rw-r--r--examples/xml/saxbookmarks/xbelhandler.cpp160
-rw-r--r--examples/xml/saxbookmarks/xbelhandler.h88
-rw-r--r--examples/xml/xml.pro1
205 files changed, 1443 insertions, 3859 deletions
diff --git a/examples/corelib/ipc/localfortuneclient/client.cpp b/examples/corelib/ipc/localfortuneclient/client.cpp
index 8d415f73aa..1ab0c34d6c 100644
--- a/examples/corelib/ipc/localfortuneclient/client.cpp
+++ b/examples/corelib/ipc/localfortuneclient/client.cpp
@@ -83,8 +83,7 @@ Client::Client(QWidget *parent)
this, &Client::requestNewFortune);
connect(quitButton, &QPushButton::clicked, this, &Client::close);
connect(socket, &QLocalSocket::readyRead, this, &Client::readFortune);
- connect(socket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error),
- this, &Client::displayError);
+ connect(socket, &QLocalSocket::errorOccurred, this, &Client::displayError);
QGridLayout *mainLayout = new QGridLayout(this);
mainLayout->addWidget(hostLabel, 0, 0);
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
index f755e060c6..64732ba980 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
@@ -95,7 +95,7 @@ QVariant MimetypeModel::data(const QModelIndex &index, int role) const
if (role != Qt::DecorationRole || !index.isValid() || index.data(iconQueriedRole).toBool())
return QStandardItemModel::data(index, role);
QStandardItem *item = itemFromIndex(index);
- const QString iconName = item->data(mimeTypeRole).value<QMimeType>().iconName();
+ const QString iconName = qvariant_cast<QMimeType>(item->data(mimeTypeRole)).iconName();
if (!iconName.isEmpty())
item->setIcon(QIcon::fromTheme(iconName));
item->setData(QVariant(true), iconQueriedRole);
@@ -104,7 +104,7 @@ QVariant MimetypeModel::data(const QModelIndex &index, int role) const
QMimeType MimetypeModel::mimeType(const QModelIndex &index) const
{
- return index.data(mimeTypeRole).value<QMimeType>();
+ return qvariant_cast<QMimeType>(index.data(mimeTypeRole));
}
void MimetypeModel::populate()
diff --git a/examples/corelib/serialization/convert/cborconverter.cpp b/examples/corelib/serialization/convert/cborconverter.cpp
index f907bb0af6..77df367e50 100644
--- a/examples/corelib/serialization/convert/cborconverter.cpp
+++ b/examples/corelib/serialization/convert/cborconverter.cpp
@@ -134,7 +134,7 @@ static QVariant convertCborValue(const QCborValue &value)
enum TrimFloatingPoint { Double, Float, Float16 };
static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrimming)
{
- if (v.userType() == QVariant::List) {
+ if (v.userType() == QMetaType::QVariantList) {
const QVariantList list = v.toList();
QCborArray array;
for (const QVariant &v : list)
@@ -144,7 +144,7 @@ static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrim
}
if (v.userType() == qMetaTypeId<VariantOrderedMap>()) {
- const auto m = v.value<VariantOrderedMap>();
+ const auto m = qvariant_cast<VariantOrderedMap>(v);
QCborMap map;
for (const auto &pair : m)
map.insert(convertFromVariant(pair.first, fpTrimming),
@@ -152,7 +152,7 @@ static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrim
return map;
}
- if (v.userType() == QVariant::Double && fpTrimming != Double) {
+ if (v.userType() == QMetaType::Double && fpTrimming != Double) {
float f = float(v.toDouble());
if (fpTrimming == Float16)
return float(qfloat16(f));
diff --git a/examples/corelib/serialization/convert/datastreamconverter.cpp b/examples/corelib/serialization/convert/datastreamconverter.cpp
index 7cdb844141..6f0ca41ff5 100644
--- a/examples/corelib/serialization/convert/datastreamconverter.cpp
+++ b/examples/corelib/serialization/convert/datastreamconverter.cpp
@@ -96,9 +96,9 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
QString indented = indent + QLatin1String(" ");
int type = v.userType();
- if (type == qMetaTypeId<VariantOrderedMap>() || type == QVariant::Map) {
- const auto map = (type == QVariant::Map) ?
- VariantOrderedMap(v.toMap()) : v.value<VariantOrderedMap>();
+ if (type == qMetaTypeId<VariantOrderedMap>() || type == QMetaType::QVariantMap) {
+ const auto map = (type == QMetaType::QVariantMap) ?
+ VariantOrderedMap(v.toMap()) : qvariant_cast<VariantOrderedMap>(v);
result = QLatin1String("Map {");
for (const auto &pair : map) {
@@ -109,7 +109,7 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
}
result.chop(1); // remove comma
result += indent + QLatin1String("},");
- } else if (type == QVariant::List) {
+ } else if (type == QMetaType::QVariantList) {
const QVariantList list = v.toList();
result = QLatin1String("List [");
diff --git a/examples/corelib/serialization/convert/jsonconverter.cpp b/examples/corelib/serialization/convert/jsonconverter.cpp
index 80d1cc6827..ec24af703d 100644
--- a/examples/corelib/serialization/convert/jsonconverter.cpp
+++ b/examples/corelib/serialization/convert/jsonconverter.cpp
@@ -57,7 +57,6 @@
#include <QJsonValue>
static JsonConverter jsonConverter;
-static BinaryJsonConverter BinaryJsonConverter;
static const char optionHelp[] =
"compact=no|yes Use compact JSON form.\n";
@@ -151,62 +150,3 @@ void JsonConverter::saveFile(QIODevice *f, const QVariant &contents, const QStri
f->write(convertFromVariant(contents).toJson(format));
}
-
-QString BinaryJsonConverter::name()
-{
- return "binary-json";
-}
-
-Converter::Direction BinaryJsonConverter::directions()
-{
- return InOut;
-}
-
-Converter::Options BinaryJsonConverter::outputOptions()
-{
- return {};
-}
-
-const char *BinaryJsonConverter::optionsHelp()
-{
- return nullptr;
-}
-
-bool BinaryJsonConverter::probeFile(QIODevice *f)
-{
- return f->isReadable() && f->peek(4) == "qbjs";
-}
-
-QVariant BinaryJsonConverter::loadFile(QIODevice *f, Converter *&outputConverter)
-{
- if (!outputConverter)
- outputConverter = &jsonConverter;
-
- QJsonDocument doc;
- if (auto file = qobject_cast<QFile *>(f)) {
- uchar *ptr = file->map(0, file->size());
- if (ptr)
- doc = QJsonDocument::fromRawData(reinterpret_cast<char *>(ptr), file->size());
- }
-
- if (doc.isNull())
- doc = QJsonDocument::fromBinaryData(f->readAll());
-
- if (!doc.isObject() && !doc.isArray()) {
- fprintf(stderr, "Failed to load Binary JSON.\n");
- exit(EXIT_FAILURE);
- }
- if (outputConverter == null)
- return QVariant();
- return doc.toVariant();
-}
-
-void BinaryJsonConverter::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options)
-{
- if (!options.isEmpty()) {
- fprintf(stderr, "Unknown option '%s' to JSON output. This format has no options.\n", qPrintable(options.first()));
- exit(EXIT_FAILURE);
- }
-
- f->write(convertFromVariant(contents).toBinaryData());
-}
diff --git a/examples/corelib/serialization/convert/jsonconverter.h b/examples/corelib/serialization/convert/jsonconverter.h
index 17170603c7..445a0e6695 100644
--- a/examples/corelib/serialization/convert/jsonconverter.h
+++ b/examples/corelib/serialization/convert/jsonconverter.h
@@ -69,17 +69,4 @@ public:
void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
};
-class BinaryJsonConverter : public Converter
-{
- // Converter interface
-public:
- QString name() override;
- Direction directions() override;
- Options outputOptions() override;
- const char *optionsHelp() override;
- bool probeFile(QIODevice *f) override;
- QVariant loadFile(QIODevice *f, Converter *&outputConverter) override;
- void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
-};
-
#endif // JSONCONVERTER_H
diff --git a/examples/corelib/serialization/convert/textconverter.cpp b/examples/corelib/serialization/convert/textconverter.cpp
index 7aed08f96c..ae03b9a334 100644
--- a/examples/corelib/serialization/convert/textconverter.cpp
+++ b/examples/corelib/serialization/convert/textconverter.cpp
@@ -56,21 +56,21 @@
static void dumpVariant(QTextStream &out, const QVariant &v)
{
switch (v.userType()) {
- case QVariant::List: {
+ case QMetaType::QVariantList: {
const QVariantList list = v.toList();
for (const QVariant &item : list)
dumpVariant(out, item);
break;
}
- case QVariant::String: {
+ case QMetaType::QString: {
const QStringList list = v.toStringList();
for (const QString &s : list)
out << s << Qt::endl;
break;
}
- case QVariant::Map: {
+ case QMetaType::QVariantMap: {
const QVariantMap map = v.toMap();
for (auto it = map.begin(); it != map.end(); ++it) {
out << it.key() << " => ";
diff --git a/examples/corelib/serialization/convert/xmlconverter.cpp b/examples/corelib/serialization/convert/xmlconverter.cpp
index e62801bf76..42cb10100a 100644
--- a/examples/corelib/serialization/convert/xmlconverter.cpp
+++ b/examples/corelib/serialization/convert/xmlconverter.cpp
@@ -284,18 +284,18 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
ba.resize(n);
result = ba;
} else {
- int id = QVariant::Invalid;
+ int id = QMetaType::UnknownType;
if (type == QLatin1String("datetime"))
- id = QVariant::DateTime;
+ id = QMetaType::QDateTime;
else if (type == QLatin1String("url"))
- id = QVariant::Url;
+ id = QMetaType::QUrl;
else if (type == QLatin1String("uuid"))
- id = QVariant::Uuid;
+ id = QMetaType::QUuid;
else if (type == QLatin1String("regex"))
- id = QVariant::RegularExpression;
+ id = QMetaType::QRegularExpression;
else
id = QMetaType::type(type.toLatin1());
- if (id == QVariant::Invalid) {
+ if (id == QMetaType::UnknownType) {
fprintf(stderr, "%lld:%lld: Invalid XML: unknown type '%s'.\n",
xml.lineNumber(), xml.columnNumber(), qPrintable(type.toString()));
exit(EXIT_FAILURE);
@@ -327,16 +327,16 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
{
int type = v.userType();
- if (type == QVariant::List) {
+ if (type == QMetaType::QVariantList) {
QVariantList list = v.toList();
xml.writeStartElement("list");
for (const QVariant &v : list)
variantToXml(xml, v);
xml.writeEndElement();
- } else if (type == QVariant::Map || type == qMetaTypeId<VariantOrderedMap>()) {
- const VariantOrderedMap map = (type == QVariant::Map) ?
+ } else if (type == QMetaType::QVariantMap || type == qMetaTypeId<VariantOrderedMap>()) {
+ const VariantOrderedMap map = (type == QMetaType::QVariantMap) ?
VariantOrderedMap(v.toMap()) :
- v.value<VariantOrderedMap>();
+ qvariant_cast<VariantOrderedMap>(v);
xml.writeStartElement("map");
for (const auto &pair : map) {
@@ -425,15 +425,15 @@ static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
default:
if (type == qMetaTypeId<qfloat16>()) {
xml.writeAttribute(typeString, "number");
- xml.writeCharacters(QString::number(float(v.value<qfloat16>())));
+ xml.writeCharacters(QString::number(float(qvariant_cast<qfloat16>(v))));
} else if (type == qMetaTypeId<QCborSimpleType>()) {
xml.writeAttribute(typeString, "CBOR simple type");
- xml.writeCharacters(QString::number(int(v.value<QCborSimpleType>())));
+ xml.writeCharacters(QString::number(int(qvariant_cast<QCborSimpleType>(v))));
} else {
// does this convert to string?
const char *typeName = v.typeName();
QVariant copy = v;
- if (copy.convert(QVariant::String)) {
+ if (copy.convert(QMetaType::QString)) {
xml.writeAttribute(typeString, QString::fromLatin1(typeName));
xml.writeCharacters(copy.toString());
} else {
diff --git a/examples/corelib/serialization/savegame/doc/src/savegame.qdoc b/examples/corelib/serialization/savegame/doc/src/savegame.qdoc
index a35f763430..e20cb6bc6c 100644
--- a/examples/corelib/serialization/savegame/doc/src/savegame.qdoc
+++ b/examples/corelib/serialization/savegame/doc/src/savegame.qdoc
@@ -37,8 +37,8 @@
game generally involves serializing each game object's member variables
to a file. Many formats can be used for this purpose, one of which is JSON.
With QJsonDocument, you also have the ability to serialize a document in a
- binary format, which is great if you don't want the save file to be
- readable, or if you need to keep the file size down.
+ \l {https://tools.ietf.org/html/rfc7049} {CBOR} format, which is great if you
+ don't want the save file to be readable, or if you need to keep the file size down.
In this example, we'll demonstrate how to save and load a simple game to
and from JSON and binary formats.
@@ -133,7 +133,7 @@
When loading a saved game in loadGame(), the first thing we do is open the
save file based on which format it was saved to; \c "save.json" for JSON,
- and \c "save.dat" for binary. We print a warning and return \c false if the
+ and \c "save.dat" for CBOR. We print a warning and return \c false if the
file couldn't be opened.
Since QJsonDocument's \l{QJsonDocument::fromJson()}{fromJson()} and
@@ -172,7 +172,7 @@
\snippet serialization/savegame/main.cpp 1
When the player has finished, we save their game. For demonstration
- purposes, we can serialize to either JSON or binary. You can examine the
+ purposes, we can serialize to either JSON or CBOR. You can examine the
contents of the files in the same directory as the executable (or re-run
the example, making sure to also specify the "load" option), although the
binary save file will contain some garbage characters (which is normal).
diff --git a/examples/corelib/serialization/savegame/game.cpp b/examples/corelib/serialization/savegame/game.cpp
index c39362bc68..58fc087b1f 100644
--- a/examples/corelib/serialization/savegame/game.cpp
+++ b/examples/corelib/serialization/savegame/game.cpp
@@ -50,6 +50,8 @@
#include "game.h"
+#include <QCborMap>
+#include <QCborValue>
#include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
@@ -122,14 +124,14 @@ bool Game::loadGame(Game::SaveFormat saveFormat)
QJsonDocument loadDoc(saveFormat == Json
? QJsonDocument::fromJson(saveData)
- : QJsonDocument::fromBinaryData(saveData));
+ : QJsonDocument(QCborValue::fromCbor(saveData).toMap().toJsonObject()));
read(loadDoc.object());
QTextStream(stdout) << "Loaded save for "
<< loadDoc["player"]["name"].toString()
<< " using "
- << (saveFormat != Json ? "binary " : "") << "JSON...\n";
+ << (saveFormat != Json ? "CBOR" : "JSON") << "...\n";
return true;
}
//! [3]
@@ -148,10 +150,9 @@ bool Game::saveGame(Game::SaveFormat saveFormat) const
QJsonObject gameObject;
write(gameObject);
- QJsonDocument saveDoc(gameObject);
saveFile.write(saveFormat == Json
- ? saveDoc.toJson()
- : saveDoc.toBinaryData());
+ ? QJsonDocument(gameObject).toJson()
+ : QCborValue::fromJsonValue(gameObject).toCbor());
return true;
}
diff --git a/examples/corelib/threads/doc/src/mandelbrot.qdoc b/examples/corelib/threads/doc/src/mandelbrot.qdoc
index b32fa097b3..2b12743538 100644
--- a/examples/corelib/threads/doc/src/mandelbrot.qdoc
+++ b/examples/corelib/threads/doc/src/mandelbrot.qdoc
@@ -187,6 +187,10 @@
generate more and more precise (and computationally expensive)
approximations of the fractal.
+ We create a high resolution pixmap by applying the device
+ pixel ratio to the target size (see
+ \l{Drawing High Resolution Versions of Pixmaps and Images}).
+
If we discover inside the loop that \c restart has been set to \c
true (by \c render()), we break out of the loop immediately, so
that the control quickly returns to the very top of the outer
@@ -273,12 +277,21 @@
\snippet threads/mandelbrot/mandelbrotwidget.cpp 8
If the pixmap has the right scale factor, we draw the pixmap directly onto
- the widget. Otherwise, we scale and translate the \l{Coordinate
- System}{coordinate system} before we draw the pixmap. By reverse mapping
- the widget's rectangle using the scaled painter matrix, we also make sure
- that only the exposed areas of the pixmap are drawn. The calls to
- QPainter::save() and QPainter::restore() make sure that any painting
- performed afterwards uses the standard coordinate system.
+ the widget.
+
+ Otherwise, we create a preview pixmap to be shown until the calculation
+ finishes and translate the \l{Coordinate System}{coordinate system}
+ accordingly.
+
+ Since we are going to use transformations on the painter
+ and use an overload of QPainter::drawPixmap() that does not support
+ high resolution pixmaps in that case, we create a pixmap with device pixel
+ ratio 1.
+
+ By reverse mapping the widget's rectangle using the scaled painter matrix,
+ we also make sure that only the exposed areas of the pixmap are drawn.
+ The calls to QPainter::save() and QPainter::restore() make sure that any
+ painting performed afterwards uses the standard coordinate system.
\snippet threads/mandelbrot/mandelbrotwidget.cpp 9
diff --git a/examples/corelib/threads/mandelbrot/main.cpp b/examples/corelib/threads/mandelbrot/main.cpp
index 9832d55514..c5d4835192 100644
--- a/examples/corelib/threads/mandelbrot/main.cpp
+++ b/examples/corelib/threads/mandelbrot/main.cpp
@@ -55,6 +55,8 @@
//! [0]
int main(int argc, char *argv[])
{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication app(argc, argv);
MandelbrotWidget widget;
widget.show();
diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
index 822791533b..f47c9c8a8b 100644
--- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
+++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
@@ -56,29 +56,28 @@
#include <math.h>
//! [0]
-const double DefaultCenterX = -0.637011f;
-const double DefaultCenterY = -0.0395159f;
-const double DefaultScale = 0.00403897f;
+const double DefaultCenterX = -0.637011;
+const double DefaultCenterY = -0.0395159;
+const double DefaultScale = 0.00403897;
-const double ZoomInFactor = 0.8f;
+const double ZoomInFactor = 0.8;
const double ZoomOutFactor = 1 / ZoomInFactor;
const int ScrollStep = 20;
//! [0]
//! [1]
-MandelbrotWidget::MandelbrotWidget(QWidget *parent)
- : QWidget(parent)
+MandelbrotWidget::MandelbrotWidget(QWidget *parent) :
+ QWidget(parent),
+ centerX(DefaultCenterX),
+ centerY(DefaultCenterY),
+ pixmapScale(DefaultScale),
+ curScale(DefaultScale)
{
- centerX = DefaultCenterX;
- centerY = DefaultCenterY;
- pixmapScale = DefaultScale;
- curScale = DefaultScale;
-
connect(&thread, &RenderThread::renderedImage,
this, &MandelbrotWidget::updatePixmap);
setWindowTitle(tr("Mandelbrot"));
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
setCursor(Qt::CrossCursor);
#endif
resize(550, 400);
@@ -102,24 +101,28 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
//! [4]
//! [5]
- if (curScale == pixmapScale) {
+ if (qFuzzyCompare(curScale, pixmapScale)) {
//! [5] //! [6]
painter.drawPixmap(pixmapOffset, pixmap);
//! [6] //! [7]
} else {
//! [7] //! [8]
+ auto previewPixmap = qFuzzyCompare(pixmap.devicePixelRatioF(), qreal(1))
+ ? pixmap
+ : pixmap.scaled(pixmap.size() / pixmap.devicePixelRatioF(), Qt::KeepAspectRatio,
+ Qt::SmoothTransformation);
double scaleFactor = pixmapScale / curScale;
- int newWidth = int(pixmap.width() * scaleFactor);
- int newHeight = int(pixmap.height() * scaleFactor);
- int newX = pixmapOffset.x() + (pixmap.width() - newWidth) / 2;
- int newY = pixmapOffset.y() + (pixmap.height() - newHeight) / 2;
+ int newWidth = int(previewPixmap.width() * scaleFactor);
+ int newHeight = int(previewPixmap.height() * scaleFactor);
+ int newX = pixmapOffset.x() + (previewPixmap.width() - newWidth) / 2;
+ int newY = pixmapOffset.y() + (previewPixmap.height() - newHeight) / 2;
painter.save();
painter.translate(newX, newY);
painter.scale(scaleFactor, scaleFactor);
QRectF exposed = painter.transform().inverted().mapRect(rect()).adjusted(-1, -1, 1, 1);
- painter.drawPixmap(exposed, pixmap, exposed);
+ painter.drawPixmap(exposed, previewPixmap, exposed);
painter.restore();
}
//! [8] //! [9]
@@ -140,7 +143,7 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
//! [10]
void MandelbrotWidget::resizeEvent(QResizeEvent * /* event */)
{
- thread.render(centerX, centerY, curScale, size());
+ thread.render(centerX, centerY, curScale, size(), devicePixelRatioF());
}
//! [10]
@@ -176,8 +179,8 @@ void MandelbrotWidget::keyPressEvent(QKeyEvent *event)
//! [12]
void MandelbrotWidget::wheelEvent(QWheelEvent *event)
{
- int numDegrees = event->angleDelta().y() / 8;
- double numSteps = numDegrees / 15.0f;
+ const int numDegrees = event->angleDelta().y() / 8;
+ const double numSteps = numDegrees / double(15);
zoom(pow(ZoomInFactor, numSteps));
}
//! [12]
@@ -209,8 +212,9 @@ void MandelbrotWidget::mouseReleaseEvent(QMouseEvent *event)
pixmapOffset += event->pos() - lastDragPos;
lastDragPos = QPoint();
- int deltaX = (width() - pixmap.width()) / 2 - pixmapOffset.x();
- int deltaY = (height() - pixmap.height()) / 2 - pixmapOffset.y();
+ const auto pixmapSize = pixmap.size() / pixmap.devicePixelRatioF();
+ int deltaX = (width() - pixmapSize.width()) / 2 - pixmapOffset.x();
+ int deltaY = (height() - pixmapSize.height()) / 2 - pixmapOffset.y();
scroll(deltaX, deltaY);
}
}
@@ -235,7 +239,7 @@ void MandelbrotWidget::zoom(double zoomFactor)
{
curScale *= zoomFactor;
update();
- thread.render(centerX, centerY, curScale, size());
+ thread.render(centerX, centerY, curScale, size(), devicePixelRatioF());
}
//! [17]
@@ -245,6 +249,6 @@ void MandelbrotWidget::scroll(int deltaX, int deltaY)
centerX += deltaX * curScale;
centerY += deltaY * curScale;
update();
- thread.render(centerX, centerY, curScale, size());
+ thread.render(centerX, centerY, curScale, size(), devicePixelRatioF());
}
//! [18]
diff --git a/examples/corelib/threads/mandelbrot/renderthread.cpp b/examples/corelib/threads/mandelbrot/renderthread.cpp
index eee44c7242..4d2009471c 100644
--- a/examples/corelib/threads/mandelbrot/renderthread.cpp
+++ b/examples/corelib/threads/mandelbrot/renderthread.cpp
@@ -57,9 +57,6 @@
RenderThread::RenderThread(QObject *parent)
: QThread(parent)
{
- restart = false;
- abort = false;
-
for (int i = 0; i < ColormapSize; ++i)
colormap[i] = rgbFromWaveLength(380.0 + (i * 400.0 / ColormapSize));
}
@@ -79,13 +76,14 @@ RenderThread::~RenderThread()
//! [2]
void RenderThread::render(double centerX, double centerY, double scaleFactor,
- QSize resultSize)
+ QSize resultSize, double devicePixelRatio)
{
QMutexLocker locker(&mutex);
this->centerX = centerX;
this->centerY = centerY;
this->scaleFactor = scaleFactor;
+ this->devicePixelRatio = devicePixelRatio;
this->resultSize = resultSize;
if (!isRunning()) {
@@ -102,10 +100,12 @@ void RenderThread::run()
{
forever {
mutex.lock();
- QSize resultSize = this->resultSize;
- double scaleFactor = this->scaleFactor;
- double centerX = this->centerX;
- double centerY = this->centerY;
+ const double devicePixelRatio = this->devicePixelRatio;
+ const QSize resultSize = this->resultSize * devicePixelRatio;
+ const double requestedScaleFactor = this->scaleFactor;
+ const double scaleFactor = requestedScaleFactor / devicePixelRatio;
+ const double centerX = this->centerX;
+ const double centerY = this->centerY;
mutex.unlock();
//! [3]
@@ -114,6 +114,7 @@ void RenderThread::run()
//! [4] //! [5]
int halfHeight = resultSize.height() / 2;
QImage image(resultSize, QImage::Format_RGB32);
+ image.setDevicePixelRatio(devicePixelRatio);
const int NumPasses = 8;
int pass = 0;
@@ -128,20 +129,20 @@ void RenderThread::run()
if (abort)
return;
- uint *scanLine =
+ auto scanLine =
reinterpret_cast<uint *>(image.scanLine(y + halfHeight));
- double ay = centerY + (y * scaleFactor);
+ const double ay = centerY + (y * scaleFactor);
for (int x = -halfWidth; x < halfWidth; ++x) {
- double ax = centerX + (x * scaleFactor);
+ const double ax = centerX + (x * scaleFactor);
double a1 = ax;
double b1 = ay;
int numIterations = 0;
do {
++numIterations;
- double a2 = (a1 * a1) - (b1 * b1) + ax;
- double b2 = (2 * a1 * b1) + ay;
+ const double a2 = (a1 * a1) - (b1 * b1) + ax;
+ const double b2 = (2 * a1 * b1) + ay;
if ((a2 * a2) + (b2 * b2) > Limit)
break;
@@ -165,7 +166,7 @@ void RenderThread::run()
pass = 4;
} else {
if (!restart)
- emit renderedImage(image, scaleFactor);
+ emit renderedImage(image, requestedScaleFactor);
//! [5] //! [6]
++pass;
}
@@ -187,9 +188,9 @@ void RenderThread::run()
//! [10]
uint RenderThread::rgbFromWaveLength(double wave)
{
- double r = 0.0;
- double g = 0.0;
- double b = 0.0;
+ double r = 0;
+ double g = 0;
+ double b = 0;
if (wave >= 380.0 && wave <= 440.0) {
r = -1.0 * (wave - 440.0) / (440.0 - 380.0);
diff --git a/examples/corelib/threads/mandelbrot/renderthread.h b/examples/corelib/threads/mandelbrot/renderthread.h
index 4f0394d554..6174e0ed3d 100644
--- a/examples/corelib/threads/mandelbrot/renderthread.h
+++ b/examples/corelib/threads/mandelbrot/renderthread.h
@@ -69,7 +69,8 @@ public:
RenderThread(QObject *parent = nullptr);
~RenderThread();
- void render(double centerX, double centerY, double scaleFactor, QSize resultSize);
+ void render(double centerX, double centerY, double scaleFactor, QSize resultSize,
+ double devicePixelRatio);
signals:
void renderedImage(const QImage &image, double scaleFactor);
@@ -78,16 +79,17 @@ protected:
void run() override;
private:
- uint rgbFromWaveLength(double wave);
+ static uint rgbFromWaveLength(double wave);
QMutex mutex;
QWaitCondition condition;
double centerX;
double centerY;
double scaleFactor;
+ double devicePixelRatio;
QSize resultSize;
- bool restart;
- bool abort;
+ bool restart = false;
+ bool abort = false;
enum { ColormapSize = 512 };
uint colormap[ColormapSize];
diff --git a/examples/corelib/tools/customtype/main.cpp b/examples/corelib/tools/customtype/main.cpp
index d50bf9efea..af8e233a19 100644
--- a/examples/corelib/tools/customtype/main.cpp
+++ b/examples/corelib/tools/customtype/main.cpp
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
qDebug() << "Stored:" << stored;
//! [retrieving a custom value]
- Message retrieved = stored.value<Message>();
+ Message retrieved = qvariant_cast<Message>(stored);
qDebug() << "Retrieved:" << retrieved;
retrieved = qvariant_cast<Message>(stored);
qDebug() << "Retrieved:" << retrieved;
diff --git a/examples/corelib/tools/customtype/message.cpp b/examples/corelib/tools/customtype/message.cpp
index e83697cb74..489ec24a4d 100644
--- a/examples/corelib/tools/customtype/message.cpp
+++ b/examples/corelib/tools/customtype/message.cpp
@@ -61,7 +61,7 @@ Message::Message(const QString &body, const QStringList &headers)
QDebug operator<<(QDebug dbg, const Message &message)
{
const QString body = message.body();
- QVector<QStringRef> pieces = body.splitRef("\r\n", QString::SkipEmptyParts);
+ QVector<QStringRef> pieces = body.splitRef(QLatin1String("\r\n"), Qt::SkipEmptyParts);
if (pieces.isEmpty())
dbg.nospace() << "Message()";
else if (pieces.size() == 1)
diff --git a/examples/embedded/flickable/flickable.cpp b/examples/embedded/flickable/flickable.cpp
index fff4bac0e6..c57ec3d111 100644
--- a/examples/embedded/flickable/flickable.cpp
+++ b/examples/embedded/flickable/flickable.cpp
@@ -98,7 +98,7 @@ public:
QPoint delta;
QPoint speed;
FlickableTicker *ticker;
- QTime timeStamp;
+ QElapsedTimer timeStamp;
QWidget *target;
QList<QEvent*> ignoreList;
};
@@ -109,7 +109,7 @@ Flickable::Flickable()
d->state = FlickablePrivate::Steady;
d->threshold = 10;
d->ticker = new FlickableTicker(this);
- d->timeStamp = QTime::currentTime();
+ d->timeStamp.start();
d->target = 0;
}
@@ -208,7 +208,7 @@ void Flickable::handleMouseRelease(QMouseEvent *event)
event->accept();
delta = event->pos() - d->pressPos;
if (d->timeStamp.elapsed() > 100) {
- d->timeStamp = QTime::currentTime();
+ d->timeStamp.start();
d->speed = delta - d->delta;
d->delta = delta;
}
@@ -253,7 +253,7 @@ void Flickable::handleMouseMove(QMouseEvent *event)
delta = event->pos() - d->pressPos;
if (delta.x() > d->threshold || delta.x() < -d->threshold ||
delta.y() > d->threshold || delta.y() < -d->threshold) {
- d->timeStamp = QTime::currentTime();
+ d->timeStamp.start();
d->state = FlickablePrivate::ManualScroll;
d->delta = QPoint(0, 0);
d->pressPos = event->pos();
@@ -266,7 +266,7 @@ void Flickable::handleMouseMove(QMouseEvent *event)
delta = event->pos() - d->pressPos;
setScrollOffset(d->offset - delta);
if (d->timeStamp.elapsed() > 100) {
- d->timeStamp = QTime::currentTime();
+ d->timeStamp.start();
d->speed = delta - d->delta;
d->delta = delta;
}
diff --git a/examples/embedded/lightmaps/mapzoom.cpp b/examples/embedded/lightmaps/mapzoom.cpp
index d82b9ad473..781d4f27e3 100644
--- a/examples/embedded/lightmaps/mapzoom.cpp
+++ b/examples/embedded/lightmaps/mapzoom.cpp
@@ -81,52 +81,9 @@ MapZoom::MapZoom()
menu->addAction(nightModeAction);
menu->addAction(osmAction);
- QNetworkConfigurationManager manager;
- if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
- // Get saved network configuration
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- const QString id =
- settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
- settings.endGroup();
-
- // If the saved network configuration is not currently discovered use the system
- // default
- QNetworkConfiguration config = manager.configurationFromIdentifier(id);
- if ((config.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- config = manager.defaultConfiguration();
- }
-
- networkSession = new QNetworkSession(config, this);
- connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
-
- networkSession->open();
- } else {
- networkSession = 0;
- }
-
setWindowTitle(tr("Light Maps"));
}
-void MapZoom::sessionOpened()
-{
- // Save the used configuration
- QNetworkConfiguration config = networkSession->configuration();
- QString id;
- if (config.type() == QNetworkConfiguration::UserChoice) {
- id = networkSession->sessionProperty(
- QLatin1String("UserChoiceConfiguration")).toString();
- } else {
- id = config.identifier();
- }
-
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
- settings.endGroup();
-}
-
void MapZoom::chooseOslo()
{
map->setCenter(59.9138204, 10.7387413);
diff --git a/examples/embedded/lightmaps/mapzoom.h b/examples/embedded/lightmaps/mapzoom.h
index 30f2e63138..3844eca718 100644
--- a/examples/embedded/lightmaps/mapzoom.h
+++ b/examples/embedded/lightmaps/mapzoom.h
@@ -53,7 +53,6 @@
#include <QMainWindow>
-class QNetworkSession;
class LightMaps;
class MapZoom : public QMainWindow
@@ -64,7 +63,6 @@ public:
MapZoom();
private slots:
- void sessionOpened();
void chooseOslo();
void chooseBerlin();
void chooseJakarta();
@@ -72,7 +70,6 @@ private slots:
private:
LightMaps *map;
- QNetworkSession *networkSession;
};
#endif \ No newline at end of file
diff --git a/examples/embedded/raycasting/raycasting.cpp b/examples/embedded/raycasting/raycasting.cpp
index 7213811213..c0a1e48fa6 100644
--- a/examples/embedded/raycasting/raycasting.cpp
+++ b/examples/embedded/raycasting/raycasting.cpp
@@ -92,7 +92,7 @@ public:
}
void updatePlayer() {
- int interval = qBound(20, watch.elapsed(), 250);
+ int interval = qBound(20ll, watch.elapsed(), 250ll);
watch.start();
angle += angleDelta * interval / 1000;
qreal step = moveDelta * interval / 1000;
@@ -106,10 +106,10 @@ public:
}
void showFps() {
- static QTime frameTick;
+ static QElapsedTimer frameTick;
static int totalFrame = 0;
if (!(totalFrame & 31)) {
- int elapsed = frameTick.elapsed();
+ const qint64 elapsed = frameTick.elapsed();
frameTick.start();
int fps = 32 * 1000 / (1 + elapsed);
setWindowTitle(QString("Raycasting (%1 FPS)").arg(fps));
@@ -355,7 +355,7 @@ protected:
}
private:
- QTime watch;
+ QElapsedTimer watch;
QBasicTimer ticker;
QImage buffer;
qreal angle;
diff --git a/examples/gui/openglwindow/main.cpp b/examples/gui/openglwindow/main.cpp
index 90c93f0d37..03a6ece06f 100644
--- a/examples/gui/openglwindow/main.cpp
+++ b/examples/gui/openglwindow/main.cpp
@@ -50,36 +50,30 @@
#include "openglwindow.h"
-#include <QtGui/QGuiApplication>
-#include <QtGui/QMatrix4x4>
-#include <QtGui/QOpenGLShaderProgram>
-#include <QtGui/QScreen>
+#include <QGuiApplication>
+#include <QMatrix4x4>
+#include <QOpenGLShaderProgram>
+#include <QScreen>
+#include <QtMath>
-#include <QtCore/qmath.h>
//! [1]
class TriangleWindow : public OpenGLWindow
{
public:
- TriangleWindow();
+ using OpenGLWindow::OpenGLWindow;
void initialize() override;
void render() override;
private:
- GLuint m_posAttr;
- GLuint m_colAttr;
- GLuint m_matrixUniform;
+ GLint m_posAttr = 0;
+ GLint m_colAttr = 0;
+ GLint m_matrixUniform = 0;
- QOpenGLShaderProgram *m_program;
- int m_frame;
+ QOpenGLShaderProgram *m_program = nullptr;
+ int m_frame = 0;
};
-
-TriangleWindow::TriangleWindow()
- : m_program(0)
- , m_frame(0)
-{
-}
//! [1]
//! [2]
@@ -128,8 +122,11 @@ void TriangleWindow::initialize()
m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
m_program->link();
m_posAttr = m_program->attributeLocation("posAttr");
+ Q_ASSERT(m_posAttr != -1);
m_colAttr = m_program->attributeLocation("colAttr");
+ Q_ASSERT(m_colAttr != -1);
m_matrixUniform = m_program->uniformLocation("matrix");
+ Q_ASSERT(m_matrixUniform != -1);
}
//! [4]
@@ -144,19 +141,19 @@ void TriangleWindow::render()
m_program->bind();
QMatrix4x4 matrix;
- matrix.perspective(60.0f, 4.0f/3.0f, 0.1f, 100.0f);
+ matrix.perspective(60.0f, 4.0f / 3.0f, 0.1f, 100.0f);
matrix.translate(0, 0, -2);
matrix.rotate(100.0f * m_frame / screen()->refreshRate(), 0, 1, 0);
m_program->setUniformValue(m_matrixUniform, matrix);
- GLfloat vertices[] = {
- 0.0f, 0.707f,
+ static const GLfloat vertices[] = {
+ 0.0f, 0.707f,
-0.5f, -0.5f,
- 0.5f, -0.5f
+ 0.5f, -0.5f
};
- GLfloat colors[] = {
+ static const GLfloat colors[] = {
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f
@@ -165,13 +162,13 @@ void TriangleWindow::render()
glVertexAttribPointer(m_posAttr, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glVertexAttribPointer(m_colAttr, 3, GL_FLOAT, GL_FALSE, 0, colors);
- glEnableVertexAttribArray(0);
- glEnableVertexAttribArray(1);
+ glEnableVertexAttribArray(m_posAttr);
+ glEnableVertexAttribArray(m_colAttr);
glDrawArrays(GL_TRIANGLES, 0, 3);
- glDisableVertexAttribArray(1);
- glDisableVertexAttribArray(0);
+ glDisableVertexAttribArray(m_colAttr);
+ glDisableVertexAttribArray(m_posAttr);
m_program->release();
diff --git a/examples/gui/openglwindow/openglwindow.cpp b/examples/gui/openglwindow/openglwindow.cpp
index a0c85006bd..bac887dca0 100644
--- a/examples/gui/openglwindow/openglwindow.cpp
+++ b/examples/gui/openglwindow/openglwindow.cpp
@@ -50,18 +50,13 @@
#include "openglwindow.h"
-#include <QtCore/QCoreApplication>
-
-#include <QtGui/QOpenGLContext>
-#include <QtGui/QOpenGLPaintDevice>
-#include <QtGui/QPainter>
+#include <QOpenGLContext>
+#include <QOpenGLPaintDevice>
+#include <QPainter>
//! [1]
OpenGLWindow::OpenGLWindow(QWindow *parent)
: QWindow(parent)
- , m_animating(false)
- , m_context(0)
- , m_device(0)
{
setSurfaceType(QWindow::OpenGLSurface);
}
diff --git a/examples/gui/openglwindow/openglwindow.h b/examples/gui/openglwindow/openglwindow.h
index 6e6c1d7449..8db943ddde 100644
--- a/examples/gui/openglwindow/openglwindow.h
+++ b/examples/gui/openglwindow/openglwindow.h
@@ -48,8 +48,8 @@
**
****************************************************************************/
-#include <QtGui/QWindow>
-#include <QtGui/QOpenGLFunctions>
+#include <QWindow>
+#include <QOpenGLFunctions>
QT_BEGIN_NAMESPACE
class QPainter;
@@ -62,7 +62,7 @@ class OpenGLWindow : public QWindow, protected QOpenGLFunctions
{
Q_OBJECT
public:
- explicit OpenGLWindow(QWindow *parent = 0);
+ explicit OpenGLWindow(QWindow *parent = nullptr);
~OpenGLWindow();
virtual void render(QPainter *painter);
@@ -82,10 +82,10 @@ protected:
void exposeEvent(QExposeEvent *event) override;
private:
- bool m_animating;
+ bool m_animating = false;
- QOpenGLContext *m_context;
- QOpenGLPaintDevice *m_device;
+ QOpenGLContext *m_context = nullptr;
+ QOpenGLPaintDevice *m_device = nullptr;
};
//! [1]
diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp
deleted file mode 100644
index 1a54f5ec8a..0000000000
--- a/examples/network/bearermonitor/bearermonitor.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 "bearermonitor.h"
-#include "sessionwidget.h"
-
-#include <QtCore/QDebug>
-
-#ifdef Q_OS_WIN
-#include <winsock2.h>
-#undef interface
-
-#ifndef NS_NLA
-#define NS_NLA 15
-#endif
-#endif
-
-BearerMonitor::BearerMonitor(QWidget *parent)
-: QWidget(parent)
-{
- setupUi(this);
- delete tabWidget->currentWidget();
- sessionGroup->hide();
- updateConfigurations();
- onlineStateChanged(!manager.allConfigurations(QNetworkConfiguration::Active).isEmpty());
- QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration();
- for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
- QTreeWidgetItem *item = treeWidget->topLevelItem(i);
-
- if (item->data(0, Qt::UserRole).toString() == defaultConfiguration.identifier()) {
- treeWidget->setCurrentItem(item);
- showConfigurationFor(item);
- break;
- }
- }
- connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool)));
- connect(&manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)),
- this, SLOT(configurationAdded(const QNetworkConfiguration&)));
- connect(&manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)),
- this, SLOT(configurationRemoved(const QNetworkConfiguration&)));
- connect(&manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)),
- this, SLOT(configurationChanged(const QNetworkConfiguration)));
- connect(&manager, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations()));
-
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
- connect(registerButton, SIGNAL(clicked()), this, SLOT(registerNetwork()));
- connect(unregisterButton, SIGNAL(clicked()), this, SLOT(unregisterNetwork()));
-#else // Q_OS_WIN && !Q_OS_WINRT
- nlaGroup->hide();
-#endif
-
- connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
- this, SLOT(createSessionFor(QTreeWidgetItem*)));
-
- connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
- this, SLOT(showConfigurationFor(QTreeWidgetItem*)));
-
- connect(newSessionButton, SIGNAL(clicked()),
- this, SLOT(createNewSession()));
- connect(deleteSessionButton, SIGNAL(clicked()),
- this, SLOT(deleteSession()));
- connect(scanButton, SIGNAL(clicked()),
- this, SLOT(performScan()));
-
- // Just in case update all configurations so that all
- // configurations are up to date.
- manager.updateConfigurations();
-}
-
-BearerMonitor::~BearerMonitor()
-{
-}
-
-static void updateItem(QTreeWidgetItem *item, const QNetworkConfiguration &config)
-{
- item->setText(0, config.name());
- item->setData(0, Qt::UserRole, config.identifier());
-
- QFont font = item->font(1);
- font.setBold((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active);
- item->setFont(0, font);
-}
-
-void BearerMonitor::configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent)
-{
- if (!config.isValid())
- return;
-
- QTreeWidgetItem *item = new QTreeWidgetItem;
- updateItem(item, config);
-
- if (parent)
- parent->addChild(item);
- else
- treeWidget->addTopLevelItem(item);
-
- if (config.type() == QNetworkConfiguration::ServiceNetwork) {
- const QList<QNetworkConfiguration> children = config.children();
- for (const QNetworkConfiguration &child : children)
- configurationAdded(child, item);
- }
-}
-
-void BearerMonitor::configurationRemoved(const QNetworkConfiguration &config)
-{
- for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
- QTreeWidgetItem *item = treeWidget->topLevelItem(i);
-
- if (item->data(0, Qt::UserRole).toString() == config.identifier()) {
- delete item;
- break;
- }
- }
-}
-
-void BearerMonitor::configurationChanged(const QNetworkConfiguration &config)
-{
- for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
- QTreeWidgetItem *item = treeWidget->topLevelItem(i);
-
- if (item->data(0, Qt::UserRole).toString() == config.identifier()) {
- updateItem(item, config);
-
- if (config.type() == QNetworkConfiguration::ServiceNetwork)
- updateSnapConfiguration(item, config);
-
- if (item == treeWidget->currentItem())
- showConfigurationFor(item);
-
- break;
- }
- }
-}
-
-void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap)
-{
- QMap<QString, QTreeWidgetItem *> itemMap;
- const QList<QTreeWidgetItem *> children = parent->takeChildren();
- for (QTreeWidgetItem *item : children)
- itemMap.insert(item->data(0, Qt::UserRole).toString(), item);
-
- QList<QNetworkConfiguration> allConfigurations = snap.children();
-
- while (!allConfigurations.isEmpty()) {
- QNetworkConfiguration config = allConfigurations.takeFirst();
-
- QTreeWidgetItem *item = itemMap.take(config.identifier());
- if (item) {
- updateItem(item, config);
-
- parent->addChild(item);
-
- if (config.type() == QNetworkConfiguration::ServiceNetwork)
- updateSnapConfiguration(item, config);
- } else {
- configurationAdded(config, parent);
- }
- }
-
- qDeleteAll(itemMap);
-}
-
-void BearerMonitor::updateConfigurations()
-{
- progressBar->hide();
- scanButton->show();
-
- // Just in case update online state, on Symbian platform
- // WLAN scan needs to be triggered initially to have their true state.
- onlineStateChanged(manager.isOnline());
-
- QList<QTreeWidgetItem *> items = treeWidget->findItems(QLatin1String("*"), Qt::MatchWildcard);
- QMap<QString, QTreeWidgetItem *> itemMap;
- while (!items.isEmpty()) {
- QTreeWidgetItem *item = items.takeFirst();
- itemMap.insert(item->data(0, Qt::UserRole).toString(), item);
- }
-
- QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration();
- QTreeWidgetItem *defaultItem = itemMap.take(defaultConfiguration.identifier());
-
- if (defaultItem) {
- updateItem(defaultItem, defaultConfiguration);
-
- if (defaultConfiguration.type() == QNetworkConfiguration::ServiceNetwork)
- updateSnapConfiguration(defaultItem, defaultConfiguration);
- } else {
- configurationAdded(defaultConfiguration);
- }
-
- QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
-
- while (!allConfigurations.isEmpty()) {
- QNetworkConfiguration config = allConfigurations.takeFirst();
-
- if (config.identifier() == defaultConfiguration.identifier())
- continue;
-
- QTreeWidgetItem *item = itemMap.take(config.identifier());
- if (item) {
- updateItem(item, config);
-
- if (config.type() == QNetworkConfiguration::ServiceNetwork)
- updateSnapConfiguration(item, config);
- } else {
- configurationAdded(config);
- }
- }
-
- qDeleteAll(itemMap);
-}
-
-void BearerMonitor::onlineStateChanged(bool isOnline)
-{
- if (isOnline)
- onlineState->setText(tr("Online"));
- else
- onlineState->setText(tr("Offline"));
-}
-
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
-void BearerMonitor::registerNetwork()
-{
- QTreeWidgetItem *item = treeWidget->currentItem();
- if (!item) return;
-
- QNetworkConfiguration configuration =
- manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString());
-
- const QString name = configuration.name();
-
- qDebug() << "Registering" << name << "with system";
-
- WSAQUERYSET networkInfo;
- memset(&networkInfo, 0, sizeof(networkInfo));
- networkInfo.dwSize = sizeof(networkInfo);
- networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16();
- networkInfo.dwNameSpace = NS_NLA;
-
- if (WSASetService(&networkInfo, RNRSERVICE_REGISTER, 0) == SOCKET_ERROR)
- qDebug() << "WSASetService(RNRSERVICE_REGISTER) returned" << WSAGetLastError();
-}
-
-void BearerMonitor::unregisterNetwork()
-{
- QTreeWidgetItem *item = treeWidget->currentItem();
- if (!item) return;
-
- QNetworkConfiguration configuration =
- manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString());
-
- const QString name = configuration.name();
-
- qDebug() << "Unregistering" << name << "with system";
-
- WSAQUERYSET networkInfo;
- memset(&networkInfo, 0, sizeof(networkInfo));
- networkInfo.dwSize = sizeof(networkInfo);
- networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16();
- networkInfo.dwNameSpace = NS_NLA;
-
- if (WSASetService(&networkInfo, RNRSERVICE_DELETE, 0) == SOCKET_ERROR)
- qDebug() << "WSASetService(RNRSERVICE_DELETE) returned" << WSAGetLastError();
-}
-#endif // Q_OS_WIN && !Q_OS_WINRT
-
-void BearerMonitor::showConfigurationFor(QTreeWidgetItem *item)
-{
- QString identifier;
-
- if (item)
- identifier = item->data(0, Qt::UserRole).toString();
-
- QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier);
-
- switch (conf.state()) {
- case QNetworkConfiguration::Active:
- configurationState->setText(tr("Active"));
- break;
- case QNetworkConfiguration::Discovered:
- configurationState->setText(tr("Discovered"));
- break;
- case QNetworkConfiguration::Defined:
- configurationState->setText(tr("Defined"));
- break;
- case QNetworkConfiguration::Undefined:
- configurationState->setText(tr("Undefined"));
- break;
- default:
- configurationState->setText(QString());
- }
-
- switch (conf.type()) {
- case QNetworkConfiguration::InternetAccessPoint:
- configurationType->setText(tr("Internet Access Point"));
- break;
- case QNetworkConfiguration::ServiceNetwork:
- configurationType->setText(tr("Service Network"));
- break;
- case QNetworkConfiguration::UserChoice:
- configurationType->setText(tr("User Choice"));
- break;
- case QNetworkConfiguration::Invalid:
- configurationType->setText(tr("Invalid"));
- break;
- default:
- configurationType->setText(QString());
- }
-
- switch (conf.purpose()) {
- case QNetworkConfiguration::UnknownPurpose:
- configurationPurpose->setText(tr("Unknown"));
- break;
- case QNetworkConfiguration::PublicPurpose:
- configurationPurpose->setText(tr("Public"));
- break;
- case QNetworkConfiguration::PrivatePurpose:
- configurationPurpose->setText(tr("Private"));
- break;
- case QNetworkConfiguration::ServiceSpecificPurpose:
- configurationPurpose->setText(tr("Service Specific"));
- break;
- default:
- configurationPurpose->setText(QString());
- }
-
- configurationIdentifier->setText(conf.identifier());
-
- configurationRoaming->setText(conf.isRoamingAvailable() ? tr("Available") : tr("Not available"));
-
- configurationChildren->setText(QString::number(conf.children().count()));
-
- configurationName->setText(conf.name());
-}
-
-void BearerMonitor::createSessionFor(QTreeWidgetItem *item)
-{
- const QString identifier = item->data(0, Qt::UserRole).toString();
-
- QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier);
-
- SessionWidget *session = new SessionWidget(conf);
-
- tabWidget->addTab(session, conf.name());
-
- sessionGroup->show();
-
- sessionWidgets.append(session);
-}
-
-void BearerMonitor::createNewSession()
-{
- QTreeWidgetItem *item = treeWidget->currentItem();
- if (!item) return;
-
- createSessionFor(item);
-}
-
-void BearerMonitor::deleteSession()
-{
- SessionWidget *session = qobject_cast<SessionWidget *>(tabWidget->currentWidget());
- if (session) {
- sessionWidgets.removeAll(session);
-
- delete session;
-
- if (tabWidget->count() == 0)
- sessionGroup->hide();
- }
-}
-
-void BearerMonitor::performScan()
-{
- scanButton->hide();
- progressBar->show();
- manager.updateConfigurations();
-}
diff --git a/examples/network/bearermonitor/bearermonitor.h b/examples/network/bearermonitor/bearermonitor.h
deleted file mode 100644
index 7de186cd14..0000000000
--- a/examples/network/bearermonitor/bearermonitor.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-#ifndef BEARERMONITOR_H
-#define BEARERMONITOR_H
-
-#include <qnetworkconfigmanager.h>
-#include <qnetworksession.h>
-#include "ui_bearermonitor_640_480.h"
-
-QT_USE_NAMESPACE
-
-class SessionWidget;
-
-class BearerMonitor : public QWidget, public Ui_BearerMonitor
-{
- Q_OBJECT
-
-public:
- BearerMonitor(QWidget *parent = 0);
- ~BearerMonitor();
-
-private slots:
- void configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent = 0);
- void configurationRemoved(const QNetworkConfiguration &config);
- void configurationChanged(const QNetworkConfiguration &config);
- void updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap);
- void updateConfigurations();
-
- void onlineStateChanged(bool isOnline);
-
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
- void registerNetwork();
- void unregisterNetwork();
-#endif // Q_OS_WIN && !Q_OS_WINRT
-
- void showConfigurationFor(QTreeWidgetItem *item);
-
- void createSessionFor(QTreeWidgetItem *item);
- void createNewSession();
- void deleteSession();
- void performScan();
-
-private:
- QNetworkConfigurationManager manager;
- QList<SessionWidget *> sessionWidgets;
-};
-
-#endif //BEARERMONITOR_H
diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro
deleted file mode 100644
index 16ac41298a..0000000000
--- a/examples/network/bearermonitor/bearermonitor.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-TARGET = bearermonitor
-QT = core gui network widgets
-requires(qtConfig(treeview))
-
-HEADERS = sessionwidget.h \
- bearermonitor.h
-
-SOURCES = main.cpp \
- bearermonitor.cpp \
- sessionwidget.cpp
-
-FORMS = bearermonitor_240_320.ui \
- bearermonitor_640_480.ui \
- sessionwidget.ui
-
-win32: QMAKE_USE += ws2_32
-
-CONFIG += console
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/network/bearermonitor
-INSTALLS += target
diff --git a/examples/network/bearermonitor/bearermonitor_240_320.ui b/examples/network/bearermonitor/bearermonitor_240_320.ui
deleted file mode 100644
index 93cfc5e0e3..0000000000
--- a/examples/network/bearermonitor/bearermonitor_240_320.ui
+++ /dev/null
@@ -1,420 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>BearerMonitor</class>
- <widget class="QWidget" name="BearerMonitor">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>240</width>
- <height>320</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>BearerMonitor</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_5">
- <item>
- <widget class="QScrollArea" name="scrollArea">
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Plain</enum>
- </property>
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>-274</y>
- <width>206</width>
- <height>576</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QGroupBox" name="systemState">
- <property name="title">
- <string>System State</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <layout class="QHBoxLayout" name="onlineStateLayout">
- <item>
- <widget class="QLabel" name="onlineStateLabel">
- <property name="text">
- <string>Online State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="onlineState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Configurations</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="configurationNameLayout">
- <item>
- <widget class="QLabel" name="configurationNameLabel">
- <property name="text">
- <string>Name:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationName">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationStateLayout">
- <item>
- <widget class="QLabel" name="configurationStateLabel">
- <property name="text">
- <string>State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationTypeLayout">
- <item>
- <widget class="QLabel" name="configurationTypeLabel">
- <property name="text">
- <string>Type:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationType">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Invalid</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationPurposeLayout">
- <item>
- <widget class="QLabel" name="configurationPurposeLabel">
- <property name="text">
- <string>Purpose:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationPurpose">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Unknown</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationIdentifierLayout">
- <item>
- <widget class="QLabel" name="configurationIdentifierLabel">
- <property name="text">
- <string>Identifier:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationIdentifier">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationRoamingLayout">
- <item>
- <widget class="QLabel" name="configurationRoamingLabel">
- <property name="text">
- <string>Roaming:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationRoaming">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationChildrenLayout">
- <item>
- <widget class="QLabel" name="configurationChildrenLabel">
- <property name="text">
- <string>Children:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationChildren">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QGroupBox" name="nlaGroup">
- <property name="title">
- <string>Network Location Awareness</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="registerButton">
- <property name="text">
- <string>Register</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="unregisterButton">
- <property name="text">
- <string>Unregister</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="newSessionButton">
- <property name="text">
- <string>New Session</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="deleteSessionButton">
- <property name="text">
- <string>Delete Session</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="scanButton">
- <property name="text">
- <string>Scan</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QProgressBar" name="progressBar">
- <property name="maximum">
- <number>0</number>
- </property>
- <property name="value">
- <number>-1</number>
- </property>
- <property name="textVisible">
- <bool>false</bool>
- </property>
- <property name="invertedAppearance">
- <bool>false</bool>
- </property>
- <property name="format">
- <string>%p%</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QTreeWidget" name="treeWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="verticalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <attribute name="headerVisible">
- <bool>false</bool>
- </attribute>
- <column>
- <property name="text">
- <string>1</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="sessionGroup">
- <property name="title">
- <string>Sessions</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QTabWidget" name="tabWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="tab">
- <attribute name="title">
- <string>Session 1</string>
- </attribute>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/network/bearermonitor/bearermonitor_640_480.ui b/examples/network/bearermonitor/bearermonitor_640_480.ui
deleted file mode 100644
index 52866bc9cd..0000000000
--- a/examples/network/bearermonitor/bearermonitor_640_480.ui
+++ /dev/null
@@ -1,386 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>BearerMonitor</class>
- <widget class="QWidget" name="BearerMonitor">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>640</width>
- <height>515</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>BearerMonitor</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QGroupBox" name="systemState">
- <property name="title">
- <string>System State</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <layout class="QHBoxLayout" name="onlineStateLayout">
- <item>
- <widget class="QLabel" name="onlineStateLabel">
- <property name="text">
- <string>Online State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="onlineState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Configurations</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QTreeWidget" name="treeWidget">
- <attribute name="headerVisible">
- <bool>false</bool>
- </attribute>
- <column>
- <property name="text">
- <string>1</string>
- </property>
- </column>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="configurationNameLayout">
- <item>
- <widget class="QLabel" name="configurationNameLabel">
- <property name="text">
- <string>Name:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationName">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationStateLayout">
- <item>
- <widget class="QLabel" name="configurationStateLabel">
- <property name="text">
- <string>State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationTypeLayout">
- <item>
- <widget class="QLabel" name="configurationTypeLabel">
- <property name="text">
- <string>Type:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationType">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Invalid</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationPurposeLayout">
- <item>
- <widget class="QLabel" name="configurationPurposeLabel">
- <property name="text">
- <string>Purpose:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationPurpose">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Unknown</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationIdentifierLayout">
- <item>
- <widget class="QLabel" name="configurationIdentifierLabel">
- <property name="text">
- <string>Identifier:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationIdentifier">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationRoamingLayout">
- <item>
- <widget class="QLabel" name="configurationRoamingLabel">
- <property name="text">
- <string>Roaming:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationRoaming">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationChildrenLayout">
- <item>
- <widget class="QLabel" name="configurationChildrenLabel">
- <property name="text">
- <string>Children:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationChildren">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QGroupBox" name="nlaGroup">
- <property name="title">
- <string>Network Location Awareness</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="registerButton">
- <property name="text">
- <string>Register</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="unregisterButton">
- <property name="text">
- <string>Unregister</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="newSessionButton">
- <property name="text">
- <string>New Session</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="deleteSessionButton">
- <property name="text">
- <string>Delete Session</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="scanButton">
- <property name="text">
- <string>Scan</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QProgressBar" name="progressBar">
- <property name="maximum">
- <number>0</number>
- </property>
- <property name="value">
- <number>-1</number>
- </property>
- <property name="textVisible">
- <bool>false</bool>
- </property>
- <property name="invertedAppearance">
- <bool>false</bool>
- </property>
- <property name="format">
- <string>%p%</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QGroupBox" name="sessionGroup">
- <property name="title">
- <string>Sessions</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QTabWidget" name="tabWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="tab">
- <attribute name="title">
- <string>Session 1</string>
- </attribute>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/network/bearermonitor/main.cpp b/examples/network/bearermonitor/main.cpp
deleted file mode 100644
index 363889dee4..0000000000
--- a/examples/network/bearermonitor/main.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 <QtWidgets/QApplication>
-#include <QtWidgets/QMainWindow>
-
-#include "bearermonitor.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QMainWindow mainWindow;
-
- BearerMonitor monitor;
-
- mainWindow.setCentralWidget(&monitor);
- mainWindow.show();
-
- return app.exec();
-}
-
diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp
deleted file mode 100644
index 237ceee2bd..0000000000
--- a/examples/network/bearermonitor/sessionwidget.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 "sessionwidget.h"
-#include "qnetworkconfigmanager.h"
-
-SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent)
-: QWidget(parent), statsTimer(-1)
-{
- setupUi(this);
-
-#ifdef QT_NO_NETWORKINTERFACE
- interfaceName->setVisible(false);
- interfaceNameLabel->setVisible(false);
- interfaceGuid->setVisible(false);
- interfaceGuidLabel->setVisible(false);
-#endif
-
- session = new QNetworkSession(config, this);
-
- connect(session, SIGNAL(stateChanged(QNetworkSession::State)),
- this, SLOT(updateSession()));
- connect(session, SIGNAL(error(QNetworkSession::SessionError)),
- this, SLOT(updateSessionError(QNetworkSession::SessionError)));
-
- updateSession();
-
- sessionId->setText(QString("0x%1").arg(qulonglong(session), 8, 16, QChar('0')));
-
- configuration->setText(session->configuration().name());
-
- connect(openSessionButton, SIGNAL(clicked()),
- this, SLOT(openSession()));
- connect(openSyncSessionButton, SIGNAL(clicked()),
- this, SLOT(openSyncSession()));
- connect(closeSessionButton, SIGNAL(clicked()),
- this, SLOT(closeSession()));
- connect(stopSessionButton, SIGNAL(clicked()),
- this, SLOT(stopSession()));
-}
-
-SessionWidget::~SessionWidget()
-{
- delete session;
-}
-
-void SessionWidget::timerEvent(QTimerEvent *e)
-{
- if (e->timerId() == statsTimer) {
- rxData->setText(QString::number(session->bytesReceived()));
- txData->setText(QString::number(session->bytesWritten()));
- activeTime->setText(QString::number(session->activeTime()));
- }
-}
-
-void SessionWidget::updateSession()
-{
- updateSessionState(session->state());
-
- if (session->state() == QNetworkSession::Connected)
- statsTimer = startTimer(1000);
- else if (statsTimer != -1)
- killTimer(statsTimer);
-
- if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint)
- bearer->setText(session->configuration().bearerTypeName());
- else {
- QNetworkConfigurationManager mgr;
- QNetworkConfiguration c = mgr.configurationFromIdentifier(session->sessionProperty("ActiveConfiguration").toString());
- bearer->setText(c.bearerTypeName());
- }
-
-#ifndef QT_NO_NETWORKINTERFACE
- interfaceName->setText(session->interface().humanReadableName());
- interfaceGuid->setText(session->interface().name());
-#endif
-}
-
-void SessionWidget::openSession()
-{
- clearError();
- session->open();
- updateSession();
-}
-
-void SessionWidget::openSyncSession()
-{
- clearError();
- session->open();
- session->waitForOpened();
- updateSession();
-}
-
-void SessionWidget::closeSession()
-{
- clearError();
- session->close();
- updateSession();
-}
-
-void SessionWidget::stopSession()
-{
- clearError();
- session->stop();
- updateSession();
-}
-
-void SessionWidget::updateSessionState(QNetworkSession::State state)
-{
- QString s = tr("%1 (%2)");
-
- switch (state) {
- case QNetworkSession::Invalid:
- s = s.arg(tr("Invalid"));
- break;
- case QNetworkSession::NotAvailable:
- s = s.arg(tr("Not Available"));
- break;
- case QNetworkSession::Connecting:
- s = s.arg(tr("Connecting"));
- break;
- case QNetworkSession::Connected:
- s = s.arg(tr("Connected"));
- break;
- case QNetworkSession::Closing:
- s = s.arg(tr("Closing"));
- break;
- case QNetworkSession::Disconnected:
- s = s.arg(tr("Disconnected"));
- break;
- case QNetworkSession::Roaming:
- s = s.arg(tr("Roaming"));
- break;
- default:
- s = s.arg(tr("Unknown"));
- }
-
- if (session->isOpen())
- s = s.arg(tr("Open"));
- else
- s = s.arg(tr("Closed"));
-
- sessionState->setText(s);
-}
-
-void SessionWidget::updateSessionError(QNetworkSession::SessionError error)
-{
- lastError->setText(QString::number(error));
- errorString->setText(session->errorString());
-}
-
-void SessionWidget::clearError()
-{
- lastError->clear();
- errorString->clear();
-}
diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h
deleted file mode 100644
index ba352eefee..0000000000
--- a/examples/network/bearermonitor/sessionwidget.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-#ifndef SESSIONWIDGET_H
-#define SESSIONWIDGET_H
-
-#include <qnetworksession.h>
-
-#include "ui_sessionwidget.h"
-
-QT_USE_NAMESPACE
-
-class SessionWidget : public QWidget, public Ui_SessionWidget
-{
- Q_OBJECT
-
-public:
- explicit SessionWidget(const QNetworkConfiguration &config, QWidget *parent = 0);
- ~SessionWidget();
-
- void timerEvent(QTimerEvent *) override;
-
-private:
- void updateSessionState(QNetworkSession::State state);
- void clearError();
-
-private Q_SLOTS:
- void openSession();
- void openSyncSession();
- void closeSession();
- void stopSession();
- void updateSession();
- void updateSessionError(QNetworkSession::SessionError error);
-
-private:
- QNetworkSession *session;
- int statsTimer;
-};
-
-#endif
-
diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui
deleted file mode 100644
index 4199109ce3..0000000000
--- a/examples/network/bearermonitor/sessionwidget.ui
+++ /dev/null
@@ -1,307 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>SessionWidget</class>
- <widget class="QWidget" name="SessionWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>340</width>
- <height>276</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Session Details</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="sessionIdLayout">
- <item>
- <widget class="QLabel" name="sessionIdLabel">
- <property name="text">
- <string>Session ID:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="sessionId">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="sessionStateLayout">
- <item>
- <widget class="QLabel" name="sessionStateLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Session State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="sessionState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Invalid</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationLayout">
- <item>
- <widget class="QLabel" name="configurationLabel">
- <property name="text">
- <string>Configuration:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configuration">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="bearerLayout">
- <item>
- <widget class="QLabel" name="bearerLabel">
- <property name="text">
- <string>Bearer:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="bearer">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="interfaceNameLayout">
- <item>
- <widget class="QLabel" name="interfaceNameLabel">
- <property name="text">
- <string>Interface Name:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="interfaceName">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="interfaceGuidLayout">
- <item>
- <widget class="QLabel" name="interfaceGuidLabel">
- <property name="text">
- <string>Interface GUID:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="interfaceGuid">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="lastErrorLayout">
- <item>
- <widget class="QLabel" name="lastErrorLabel">
- <property name="text">
- <string>Last Error:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="lastError">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="errorStringLayout">
- <item>
- <widget class="QLabel" name="errorStringLabel">
- <property name="text">
- <string>Error String:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="errorString">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="rxData">
- <property name="text">
- <string>0</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="txData">
- <property name="text">
- <string>0</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Active Time:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="activeTime">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>0 seconds</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="openSessionButton">
- <property name="text">
- <string>Open</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="openSyncSessionButton">
- <property name="text">
- <string>Blocking Open</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QPushButton" name="closeSessionButton">
- <property name="text">
- <string>Close</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="stopSessionButton">
- <property name="text">
- <string>Stop</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/network/blockingfortuneclient/blockingclient.cpp b/examples/network/blockingfortuneclient/blockingclient.cpp
index 607215cf13..5a1500d084 100644
--- a/examples/network/blockingfortuneclient/blockingclient.cpp
+++ b/examples/network/blockingfortuneclient/blockingclient.cpp
@@ -96,20 +96,21 @@ BlockingClient::BlockingClient(QWidget *parent)
buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
- connect(getFortuneButton, SIGNAL(clicked()), this, SLOT(requestNewFortune()));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
-
- connect(hostLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(enableGetFortuneButton()));
- connect(portLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(enableGetFortuneButton()));
+ connect(getFortuneButton, &QPushButton::clicked,
+ this, &BlockingClient::requestNewFortune);
+ connect(quitButton, &QPushButton::clicked,
+ this, &BlockingClient::close);
+
+ connect(hostLineEdit, &QLineEdit::textChanged,
+ this, &BlockingClient::enableGetFortuneButton);
+ connect(portLineEdit, &QLineEdit::textChanged,
+ this, &BlockingClient::enableGetFortuneButton);
+//! [0]
+ connect(&thread, &FortuneThread::newFortune,
+ this, &BlockingClient::showFortune);
+ connect(&thread, &FortuneThread::error,
+ this, &BlockingClient::displayError);
//! [0]
- connect(&thread, SIGNAL(newFortune(QString)),
- this, SLOT(showFortune(QString)));
-//! [0] //! [1]
- connect(&thread, SIGNAL(error(int,QString)),
- this, SLOT(displayError(int,QString)));
-//! [1]
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(hostLabel, 0, 0);
@@ -124,30 +125,30 @@ BlockingClient::BlockingClient(QWidget *parent)
portLineEdit->setFocus();
}
-//! [2]
+//! [1]
void BlockingClient::requestNewFortune()
{
getFortuneButton->setEnabled(false);
thread.requestNewFortune(hostLineEdit->text(),
portLineEdit->text().toInt());
}
-//! [2]
+//! [1]
-//! [3]
+//! [2]
void BlockingClient::showFortune(const QString &nextFortune)
{
if (nextFortune == currentFortune) {
requestNewFortune();
return;
}
-//! [3]
+//! [2]
-//! [4]
+//! [3]
currentFortune = nextFortune;
statusLabel->setText(currentFortune);
getFortuneButton->setEnabled(true);
}
-//! [4]
+//! [3]
void BlockingClient::displayError(int socketError, const QString &message)
{
diff --git a/examples/network/blockingfortuneclient/blockingclient.h b/examples/network/blockingfortuneclient/blockingclient.h
index 2a2dd81b71..b8a7163160 100644
--- a/examples/network/blockingfortuneclient/blockingclient.h
+++ b/examples/network/blockingfortuneclient/blockingclient.h
@@ -69,7 +69,7 @@ class BlockingClient : public QWidget
Q_OBJECT
public:
- BlockingClient(QWidget *parent = 0);
+ BlockingClient(QWidget *parent = nullptr);
private slots:
void requestNewFortune();
diff --git a/examples/network/blockingfortuneclient/fortunethread.h b/examples/network/blockingfortuneclient/fortunethread.h
index 0cbc3961fc..b6b63d9319 100644
--- a/examples/network/blockingfortuneclient/fortunethread.h
+++ b/examples/network/blockingfortuneclient/fortunethread.h
@@ -61,7 +61,7 @@ class FortuneThread : public QThread
Q_OBJECT
public:
- FortuneThread(QObject *parent = 0);
+ FortuneThread(QObject *parent = nullptr);
~FortuneThread();
void requestNewFortune(const QString &hostName, quint16 port);
diff --git a/examples/network/broadcastreceiver/receiver.cpp b/examples/network/broadcastreceiver/receiver.cpp
index 2f111b4795..5b932a27b9 100644
--- a/examples/network/broadcastreceiver/receiver.cpp
+++ b/examples/network/broadcastreceiver/receiver.cpp
@@ -48,8 +48,10 @@
**
****************************************************************************/
-#include <QtWidgets>
-#include <QtNetwork>
+#include <QLabel>
+#include <QPushButton>
+#include <QUdpSocket>
+#include <QVBoxLayout>
#include "receiver.h"
@@ -67,10 +69,11 @@ Receiver::Receiver(QWidget *parent)
//! [0]
//! [1]
- connect(udpSocket, SIGNAL(readyRead()),
- this, SLOT(processPendingDatagrams()));
+ connect(udpSocket, &QUdpSocket::readyRead,
+ this, &Receiver::processPendingDatagrams);
//! [1]
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(quitButton, &QPushButton::clicked,
+ this, &Receiver::close);
auto buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
diff --git a/examples/network/dnslookup/dnslookup.cpp b/examples/network/dnslookup/dnslookup.cpp
index a2d927d43d..61f8d35a3d 100644
--- a/examples/network/dnslookup/dnslookup.cpp
+++ b/examples/network/dnslookup/dnslookup.cpp
@@ -151,9 +151,9 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, DnsQuery *qu
//! [0]
DnsManager::DnsManager()
+ : dns(new QDnsLookup(this))
{
- dns = new QDnsLookup(this);
- connect(dns, SIGNAL(finished()), this, SLOT(showResults()));
+ connect(dns, &QDnsLookup::finished, this, &DnsManager::showResults);
}
void DnsManager::execute()
diff --git a/examples/network/doc/src/blockingfortuneclient.qdoc b/examples/network/doc/src/blockingfortuneclient.qdoc
index ecb9a7ba62..d1c0aa79bf 100644
--- a/examples/network/doc/src/blockingfortuneclient.qdoc
+++ b/examples/network/doc/src/blockingfortuneclient.qdoc
@@ -176,21 +176,20 @@
but its implementation is slightly different:
\snippet blockingfortuneclient/blockingclient.cpp 0
- \snippet blockingfortuneclient/blockingclient.cpp 1
We connect our FortuneThread's two signals newFortune() and error() (which
are somewhat similar to QTcpSocket::readyRead() and QTcpSocket::error() in
the previous example) to requestNewFortune() and displayError().
- \snippet blockingfortuneclient/blockingclient.cpp 2
+ \snippet blockingfortuneclient/blockingclient.cpp 1
The requestNewFortune() slot calls FortuneThread::requestNewFortune(),
which \e shedules the request. When the thread has received a new fortune
and emits newFortune(), our showFortune() slot is called:
- \snippet blockingfortuneclient/blockingclient.cpp 3
+ \snippet blockingfortuneclient/blockingclient.cpp 2
\codeline
- \snippet blockingfortuneclient/blockingclient.cpp 4
+ \snippet blockingfortuneclient/blockingclient.cpp 3
Here, we simply display the fortune we received as the argument.
diff --git a/examples/network/doc/src/fortuneclient.qdoc b/examples/network/doc/src/fortuneclient.qdoc
index 544fa156b7..4cb7544fc0 100644
--- a/examples/network/doc/src/fortuneclient.qdoc
+++ b/examples/network/doc/src/fortuneclient.qdoc
@@ -89,7 +89,7 @@
The only QTcpSocket signals we need in this example are
QTcpSocket::readyRead(), signifying that data has been received, and
- QTcpSocket::error(), which we will use to catch any connection errors:
+ QTcpSocket::errorOccurred(), which we will use to catch any connection errors:
\dots
\snippet fortuneclient/client.cpp 3
@@ -118,11 +118,11 @@
\li \e{An error occurs.} We need to inform the user if the connection
failed or was broken. In this case, QTcpSocket will emit
- \l{QTcpSocket::error()}{error()}, and \c Client::displayError() will be
+ \l{QTcpSocket::errorOccurred()}{errorOccurred()}, and \c Client::displayError() will be
called.
\endlist
- Let's go through the \l{QTcpSocket::error()}{error()} case first:
+ Let's go through the \l{QTcpSocket::errorOccurred()}{errorOccurred()} case first:
\snippet fortuneclient/client.cpp 13
diff --git a/examples/network/download/main.cpp b/examples/network/download/main.cpp
index 96111983ea..076dfdfd0b 100644
--- a/examples/network/download/main.cpp
+++ b/examples/network/download/main.cpp
@@ -80,8 +80,8 @@ public slots:
DownloadManager::DownloadManager()
{
- connect(&manager, SIGNAL(finished(QNetworkReply*)),
- SLOT(downloadFinished(QNetworkReply*)));
+ connect(&manager, &QNetworkAccessManager::finished,
+ this, &DownloadManager::downloadFinished);
}
void DownloadManager::doDownload(const QUrl &url)
@@ -90,8 +90,8 @@ void DownloadManager::doDownload(const QUrl &url)
QNetworkReply *reply = manager.get(request);
#if QT_CONFIG(ssl)
- connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
- SLOT(sslErrors(QList<QSslError>)));
+ connect(reply, &QNetworkReply::sslErrors,
+ this, &DownloadManager::sslErrors);
#endif
currentDownloads.append(reply);
diff --git a/examples/network/downloadmanager/downloadmanager.cpp b/examples/network/downloadmanager/downloadmanager.cpp
index 9e0c03c6af..cbad29541a 100644
--- a/examples/network/downloadmanager/downloadmanager.cpp
+++ b/examples/network/downloadmanager/downloadmanager.cpp
@@ -67,13 +67,13 @@ void DownloadManager::append(const QStringList &urls)
append(QUrl::fromEncoded(urlAsString.toLocal8Bit()));
if (downloadQueue.isEmpty())
- QTimer::singleShot(0, this, SIGNAL(finished()));
+ QTimer::singleShot(0, this, &DownloadManager::finished);
}
void DownloadManager::append(const QUrl &url)
{
if (downloadQueue.isEmpty())
- QTimer::singleShot(0, this, SLOT(startNextDownload()));
+ QTimer::singleShot(0, this, &DownloadManager::startNextDownload);
downloadQueue.enqueue(url);
++totalCount;
@@ -123,12 +123,12 @@ void DownloadManager::startNextDownload()
QNetworkRequest request(url);
currentDownload = manager.get(request);
- connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)),
- SLOT(downloadProgress(qint64,qint64)));
- connect(currentDownload, SIGNAL(finished()),
- SLOT(downloadFinished()));
- connect(currentDownload, SIGNAL(readyRead()),
- SLOT(downloadReadyRead()));
+ connect(currentDownload, &QNetworkReply::downloadProgress,
+ this, &DownloadManager::downloadProgress);
+ connect(currentDownload, &QNetworkReply::finished,
+ this, &DownloadManager::downloadFinished);
+ connect(currentDownload, &QNetworkReply::readyRead,
+ this, &DownloadManager::downloadReadyRead);
// prepare the output
printf("Downloading %s...\n", url.toEncoded().constData());
diff --git a/examples/network/downloadmanager/main.cpp b/examples/network/downloadmanager/main.cpp
index e3ba490992..eb1bd1ce9a 100644
--- a/examples/network/downloadmanager/main.cpp
+++ b/examples/network/downloadmanager/main.cpp
@@ -76,6 +76,7 @@ int main(int argc, char **argv)
DownloadManager manager;
manager.append(arguments);
- QObject::connect(&manager, SIGNAL(finished()), &app, SLOT(quit()));
+ QObject::connect(&manager, &DownloadManager::finished,
+ &app, &QCoreApplication::quit);
app.exec();
}
diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp
index 4d3a318a7b..2daac33c2b 100644
--- a/examples/network/fortuneclient/client.cpp
+++ b/examples/network/fortuneclient/client.cpp
@@ -121,7 +121,7 @@ Client::Client(QWidget *parent)
//! [2] //! [3]
connect(tcpSocket, &QIODevice::readyRead, this, &Client::readFortune);
//! [2] //! [4]
- connect(tcpSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
+ connect(tcpSocket, &QAbstractSocket::errorOccurred,
//! [3]
this, &Client::displayError);
//! [4]
@@ -150,29 +150,6 @@ Client::Client(QWidget *parent)
setWindowTitle(QGuiApplication::applicationDisplayName());
portLineEdit->setFocus();
-
- QNetworkConfigurationManager manager;
- if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
- // Get saved network configuration
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
- settings.endGroup();
-
- // If the saved network configuration is not currently discovered use the system default
- QNetworkConfiguration config = manager.configurationFromIdentifier(id);
- if ((config.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- config = manager.defaultConfiguration();
- }
-
- networkSession = new QNetworkSession(config, this);
- connect(networkSession, &QNetworkSession::opened, this, &Client::sessionOpened);
-
- getFortuneButton->setEnabled(false);
- statusLabel->setText(tr("Opening network session."));
- networkSession->open();
- }
//! [5]
}
//! [5]
@@ -241,30 +218,7 @@ void Client::displayError(QAbstractSocket::SocketError socketError)
void Client::enableGetFortuneButton()
{
- getFortuneButton->setEnabled((!networkSession || networkSession->isOpen()) &&
- !hostCombo->currentText().isEmpty() &&
+ getFortuneButton->setEnabled(!hostCombo->currentText().isEmpty() &&
!portLineEdit->text().isEmpty());
}
-
-void Client::sessionOpened()
-{
- // Save the used configuration
- QNetworkConfiguration config = networkSession->configuration();
- QString id;
- if (config.type() == QNetworkConfiguration::UserChoice)
- id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString();
- else
- id = config.identifier();
-
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
- settings.endGroup();
-
- statusLabel->setText(tr("This examples requires that you run the "
- "Fortune Server example as well."));
-
- enableGetFortuneButton();
-}
-
diff --git a/examples/network/fortuneclient/client.h b/examples/network/fortuneclient/client.h
index ac335acb83..80177bacbf 100644
--- a/examples/network/fortuneclient/client.h
+++ b/examples/network/fortuneclient/client.h
@@ -61,7 +61,6 @@ class QLabel;
class QLineEdit;
class QPushButton;
class QTcpSocket;
-class QNetworkSession;
QT_END_NAMESPACE
//! [0]
@@ -77,7 +76,6 @@ private slots:
void readFortune();
void displayError(QAbstractSocket::SocketError socketError);
void enableGetFortuneButton();
- void sessionOpened();
private:
QComboBox *hostCombo = nullptr;
@@ -88,8 +86,6 @@ private:
QTcpSocket *tcpSocket = nullptr;
QDataStream in;
QString currentFortune;
-
- QNetworkSession *networkSession = nullptr;
};
//! [0]
diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp
index 7db81fe07a..c91b6a5c0c 100644
--- a/examples/network/fortuneserver/server.cpp
+++ b/examples/network/fortuneserver/server.cpp
@@ -61,29 +61,7 @@ Server::Server(QWidget *parent)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
statusLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
- QNetworkConfigurationManager manager;
- if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
- // Get saved network configuration
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
- settings.endGroup();
-
- // If the saved network configuration is not currently discovered use the system default
- QNetworkConfiguration config = manager.configurationFromIdentifier(id);
- if ((config.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- config = manager.defaultConfiguration();
- }
-
- networkSession = new QNetworkSession(config, this);
- connect(networkSession, &QNetworkSession::opened, this, &Server::sessionOpened);
-
- statusLabel->setText(tr("Opening network session."));
- networkSession->open();
- } else {
- sessionOpened();
- }
+ initServer();
//! [2]
fortunes << tr("You've been leading a dog's life. Stay off the furniture.")
@@ -128,23 +106,8 @@ Server::Server(QWidget *parent)
setWindowTitle(QGuiApplication::applicationDisplayName());
}
-void Server::sessionOpened()
+void Server::initServer()
{
- // Save the used configuration
- if (networkSession) {
- QNetworkConfiguration config = networkSession->configuration();
- QString id;
- if (config.type() == QNetworkConfiguration::UserChoice)
- id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString();
- else
- id = config.identifier();
-
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
- settings.endGroup();
- }
-
//! [0] //! [1]
tcpServer = new QTcpServer(this);
if (!tcpServer->listen()) {
diff --git a/examples/network/fortuneserver/server.h b/examples/network/fortuneserver/server.h
index c5bfa7d928..96d7145148 100644
--- a/examples/network/fortuneserver/server.h
+++ b/examples/network/fortuneserver/server.h
@@ -58,7 +58,6 @@
QT_BEGIN_NAMESPACE
class QLabel;
class QTcpServer;
-class QNetworkSession;
QT_END_NAMESPACE
//! [0]
@@ -70,14 +69,14 @@ public:
explicit Server(QWidget *parent = nullptr);
private slots:
- void sessionOpened();
void sendFortune();
private:
+ void initServer();
+
QLabel *statusLabel = nullptr;
QTcpServer *tcpServer = nullptr;
QVector<QString> fortunes;
- QNetworkSession *networkSession = nullptr;
};
//! [0]
diff --git a/examples/network/googlesuggest/googlesuggest.cpp b/examples/network/googlesuggest/googlesuggest.cpp
index d27beafd1e..2cba43178e 100644
--- a/examples/network/googlesuggest/googlesuggest.cpp
+++ b/examples/network/googlesuggest/googlesuggest.cpp
@@ -48,9 +48,9 @@
**
****************************************************************************/
-//! [1]
#include "googlesuggest.h"
+//! [1]
const QString gsuggestUrl(QStringLiteral("http://google.com/complete/search?output=toolbar&q=%1"));
//! [1]
@@ -74,16 +74,18 @@ GSuggestCompletion::GSuggestCompletion(QLineEdit *parent): QObject(parent), edit
popup->installEventFilter(this);
- connect(popup, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
- SLOT(doneCompletion()));
+ connect(popup, &QTreeWidget::itemClicked,
+ this, &GSuggestCompletion::doneCompletion);
timer.setSingleShot(true);
timer.setInterval(500);
- connect(&timer, SIGNAL(timeout()), SLOT(autoSuggest()));
- connect(editor, SIGNAL(textEdited(QString)), &timer, SLOT(start()));
+ connect(&timer, &QTimer::timeout,
+ this, &GSuggestCompletion::autoSuggest);
+ connect(editor, &QLineEdit::textEdited,
+ &timer, QOverload<>::of(&QTimer::start));
- connect(&networkManager, SIGNAL(finished(QNetworkReply*)),
- this, SLOT(handleNetworkData(QNetworkReply*)));
+ connect(&networkManager, &QNetworkAccessManager::finished,
+ this, &GSuggestCompletion::handleNetworkData);
}
//! [2]
diff --git a/examples/network/googlesuggest/searchbox.cpp b/examples/network/googlesuggest/searchbox.cpp
index d0bdb70daa..9057c1ccdf 100644
--- a/examples/network/googlesuggest/searchbox.cpp
+++ b/examples/network/googlesuggest/searchbox.cpp
@@ -57,11 +57,11 @@
const QString gsearchUrl = QStringLiteral("http://www.google.com/search?q=%1");
//! [1]
-SearchBox::SearchBox(QWidget *parent): QLineEdit(parent)
+SearchBox::SearchBox(QWidget *parent)
+ : QLineEdit(parent)
+ , completer(new GSuggestCompletion(this))
{
- completer = new GSuggestCompletion(this);
-
- connect(this, SIGNAL(returnPressed()),this, SLOT(doSearch()));
+ connect(this, &SearchBox::returnPressed, this, &SearchBox::doSearch);
setWindowTitle("Search with Google");
diff --git a/examples/network/http/http.pro b/examples/network/http/http.pro
index 2f2d3b00ae..f67cd01495 100644
--- a/examples/network/http/http.pro
+++ b/examples/network/http/http.pro
@@ -1,4 +1,8 @@
QT += network widgets
+android: qtHaveModule(androidextras) {
+ QT += androidextras
+ DEFINES += REQUEST_PERMISSIONS_ON_ANDROID
+}
HEADERS += httpwindow.h
SOURCES += httpwindow.cpp \
diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp
index f126c7846a..6c86933fd6 100644
--- a/examples/network/http/main.cpp
+++ b/examples/network/http/main.cpp
@@ -53,16 +53,39 @@
#include <QScreen>
#include "httpwindow.h"
+#ifdef REQUEST_PERMISSIONS_ON_ANDROID
+#include <QtAndroid>
+
+bool requestStoragePermission() {
+ using namespace QtAndroid;
+
+ QString permission = QStringLiteral("android.permission.WRITE_EXTERNAL_STORAGE");
+ const QHash<QString, PermissionResult> results = requestPermissionsSync(QStringList({permission}));
+ if (!results.contains(permission) || results[permission] == PermissionResult::Denied) {
+ qWarning() << "Couldn't get permission: " << permission;
+ return false;
+ }
+
+ return true;
+}
+#endif
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
-
+#ifdef REQUEST_PERMISSIONS_ON_ANDROID
+ if (!requestStoragePermission())
+ return -1;
+#endif
HttpWindow httpWin;
const QRect availableSize = httpWin.screen()->availableGeometry();
httpWin.resize(availableSize.width() / 5, availableSize.height() / 5);
httpWin.move((availableSize.width() - httpWin.width()) / 2, (availableSize.height() - httpWin.height()) / 2);
-
+#ifdef Q_OS_ANDROID
+ httpWin.showMaximized();
+#else
httpWin.show();
+#endif
+
return app.exec();
}
diff --git a/examples/network/loopback/dialog.cpp b/examples/network/loopback/dialog.cpp
index d87f024031..4037f4c085 100644
--- a/examples/network/loopback/dialog.cpp
+++ b/examples/network/loopback/dialog.cpp
@@ -78,7 +78,7 @@ Dialog::Dialog(QWidget *parent)
connect(&tcpClient, &QAbstractSocket::connected, this, &Dialog::startTransfer);
connect(&tcpClient, &QIODevice::bytesWritten,
this, &Dialog::updateClientProgress);
- connect(&tcpClient, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
+ connect(&tcpClient, &QAbstractSocket::errorOccurred,
this, &Dialog::displayError);
QVBoxLayout *mainLayout = new QVBoxLayout;
@@ -131,8 +131,7 @@ void Dialog::acceptConnection()
connect(tcpServerConnection, &QIODevice::readyRead,
this, &Dialog::updateServerProgress);
- connect(tcpServerConnection,
- QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
+ connect(tcpServerConnection, &QAbstractSocket::errorOccurred,
this, &Dialog::displayError);
connect(tcpServerConnection, &QTcpSocket::disconnected,
tcpServerConnection, &QTcpSocket::deleteLater);
diff --git a/examples/network/multicastreceiver/receiver.cpp b/examples/network/multicastreceiver/receiver.cpp
index d793242ad0..3737d64f96 100644
--- a/examples/network/multicastreceiver/receiver.cpp
+++ b/examples/network/multicastreceiver/receiver.cpp
@@ -80,10 +80,12 @@ Receiver::Receiver(QWidget *parent)
!udpSocket6.joinMulticastGroup(groupAddress6))
statusLabel->setText(tr("Listening for multicast messages on IPv4 only"));
- connect(&udpSocket4, SIGNAL(readyRead()),
- this, SLOT(processPendingDatagrams()));
- connect(&udpSocket6, &QUdpSocket::readyRead, this, &Receiver::processPendingDatagrams);
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(&udpSocket4, &QUdpSocket::readyRead,
+ this, &Receiver::processPendingDatagrams);
+ connect(&udpSocket6, &QUdpSocket::readyRead,
+ this, &Receiver::processPendingDatagrams);
+ connect(quitButton, &QPushButton::clicked,
+ this, &Receiver::close);
}
void Receiver::processPendingDatagrams()
diff --git a/examples/network/multistreamclient/client.cpp b/examples/network/multistreamclient/client.cpp
index 112fb2e1a0..ce84f3df9a 100644
--- a/examples/network/multistreamclient/client.cpp
+++ b/examples/network/multistreamclient/client.cpp
@@ -126,8 +126,7 @@ Client::Client(QWidget *parent)
connect(sctpSocket, &QSctpSocket::connected, this, &Client::connected);
connect(sctpSocket, &QSctpSocket::disconnected, this, &Client::disconnected);
connect(sctpSocket, &QSctpSocket::channelReadyRead, this, &Client::readDatagram);
- connect(sctpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(displayError(QAbstractSocket::SocketError)));
+ connect(sctpSocket, &QSctpSocket::errorOccurred, this, &Client::displayError);
connect(consumers[SctpChannels::Time], &Consumer::writeDatagram, this, &Client::writeDatagram);
connect(consumers[SctpChannels::Chat], &Consumer::writeDatagram, this, &Client::writeDatagram);
diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp
index 615df3a318..ce6e39a8fc 100644
--- a/examples/network/network-chat/chatdialog.cpp
+++ b/examples/network/network-chat/chatdialog.cpp
@@ -62,14 +62,14 @@ ChatDialog::ChatDialog(QWidget *parent)
textEdit->setReadOnly(true);
listWidget->setFocusPolicy(Qt::NoFocus);
- connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
- connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
- connect(&client, SIGNAL(newMessage(QString,QString)),
- this, SLOT(appendMessage(QString,QString)));
- connect(&client, SIGNAL(newParticipant(QString)),
- this, SLOT(newParticipant(QString)));
- connect(&client, SIGNAL(participantLeft(QString)),
- this, SLOT(participantLeft(QString)));
+ connect(lineEdit, &QLineEdit::returnPressed,
+ this, &ChatDialog::returnPressed);
+ connect(&client, &Client::newMessage,
+ this, &ChatDialog::appendMessage);
+ connect(&client, &Client::newParticipant,
+ this, &ChatDialog::newParticipant);
+ connect(&client, &Client::participantLeft,
+ this, &ChatDialog::participantLeft);
myNickName = client.nickName();
newParticipant(myNickName);
diff --git a/examples/network/network-chat/chatdialog.h b/examples/network/network-chat/chatdialog.h
index c65861c6e6..27ae0ca72a 100644
--- a/examples/network/network-chat/chatdialog.h
+++ b/examples/network/network-chat/chatdialog.h
@@ -59,7 +59,7 @@ class ChatDialog : public QDialog, private Ui::ChatDialog
Q_OBJECT
public:
- ChatDialog(QWidget *parent = 0);
+ ChatDialog(QWidget *parent = nullptr);
public slots:
void appendMessage(const QString &from, const QString &message);
diff --git a/examples/network/network-chat/client.cpp b/examples/network/network-chat/client.cpp
index b76ef18238..fe35d535f4 100644
--- a/examples/network/network-chat/client.cpp
+++ b/examples/network/network-chat/client.cpp
@@ -60,10 +60,10 @@ Client::Client()
peerManager->setServerPort(server.serverPort());
peerManager->startBroadcasting();
- QObject::connect(peerManager, SIGNAL(newConnection(Connection*)),
- this, SLOT(newConnection(Connection*)));
- QObject::connect(&server, SIGNAL(newConnection(Connection*)),
- this, SLOT(newConnection(Connection*)));
+ connect(peerManager, &PeerManager::newConnection,
+ this, &Client::newConnection);
+ connect(&server, &Server::newConnection,
+ this, &Client::newConnection);
}
void Client::sendMessage(const QString &message)
@@ -102,10 +102,9 @@ void Client::newConnection(Connection *connection)
{
connection->setGreetingMessage(peerManager->userName());
- connect(connection, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(connectionError(QAbstractSocket::SocketError)));
- connect(connection, SIGNAL(disconnected()), this, SLOT(disconnected()));
- connect(connection, SIGNAL(readyForUse()), this, SLOT(readyForUse()));
+ connect(connection, &Connection::errorOccurred, this, &Client::connectionError);
+ connect(connection, &Connection::disconnected, this, &Client::disconnected);
+ connect(connection, &Connection::readyForUse, this, &Client::readyForUse);
}
void Client::readyForUse()
@@ -115,8 +114,8 @@ void Client::readyForUse()
connection->peerPort()))
return;
- connect(connection, SIGNAL(newMessage(QString,QString)),
- this, SIGNAL(newMessage(QString,QString)));
+ connect(connection, &Connection::newMessage,
+ this, &Client::newMessage);
peers.insert(connection->peerAddress(), connection);
QString nick = connection->name();
diff --git a/examples/network/network-chat/connection.cpp b/examples/network/network-chat/connection.cpp
index 58cf67eb6d..cffd495349 100644
--- a/examples/network/network-chat/connection.cpp
+++ b/examples/network/network-chat/connection.cpp
@@ -82,11 +82,14 @@ Connection::Connection(QObject *parent)
isGreetingMessageSent = false;
pingTimer.setInterval(PingInterval);
- QObject::connect(this, SIGNAL(readyRead()), this, SLOT(processReadyRead()));
- QObject::connect(this, SIGNAL(disconnected()), &pingTimer, SLOT(stop()));
- QObject::connect(&pingTimer, SIGNAL(timeout()), this, SLOT(sendPing()));
- QObject::connect(this, SIGNAL(connected()),
- this, SLOT(sendGreetingMessage()));
+ connect(this, &QTcpSocket::readyRead, this,
+ &Connection::processReadyRead);
+ connect(this, &QTcpSocket::disconnected,
+ &pingTimer, &QTimer::stop);
+ connect(&pingTimer, &QTimer::timeout,
+ this, &Connection::sendPing);
+ connect(this, &QTcpSocket::connected,
+ this, &Connection::sendGreetingMessage);
}
Connection::Connection(qintptr socketDescriptor, QObject *parent)
diff --git a/examples/network/network-chat/connection.h b/examples/network/network-chat/connection.h
index fa0671a522..e6f36f7cd9 100644
--- a/examples/network/network-chat/connection.h
+++ b/examples/network/network-chat/connection.h
@@ -79,8 +79,8 @@ public:
Undefined
};
- Connection(QObject *parent = 0);
- Connection(qintptr socketDescriptor, QObject *parent = 0);
+ Connection(QObject *parent = nullptr);
+ Connection(qintptr socketDescriptor, QObject *parent = nullptr);
~Connection();
QString name() const;
diff --git a/examples/network/network-chat/main.cpp b/examples/network/network-chat/main.cpp
index f88e29977b..029c18f0ff 100644
--- a/examples/network/network-chat/main.cpp
+++ b/examples/network/network-chat/main.cpp
@@ -53,50 +53,11 @@
#include "chatdialog.h"
#include <QtCore/QSettings>
-#include <QtNetwork/QNetworkConfigurationManager>
-#include <QtNetwork/QNetworkSession>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QNetworkConfigurationManager manager;
- if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
- // Get saved network configuration
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
- settings.endGroup();
-
- // If the saved network configuration is not currently discovered use the system default
- QNetworkConfiguration config = manager.configurationFromIdentifier(id);
- if ((config.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- config = manager.defaultConfiguration();
- }
-
- QNetworkSession *networkSession = new QNetworkSession(config, &app);
- networkSession->open();
- networkSession->waitForOpened();
-
- if (networkSession->isOpen()) {
- // Save the used configuration
- QNetworkConfiguration config = networkSession->configuration();
- QString id;
- if (config.type() == QNetworkConfiguration::UserChoice) {
- id = networkSession->sessionProperty(
- QLatin1String("UserChoiceConfiguration")).toString();
- } else {
- id = config.identifier();
- }
-
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
- settings.endGroup();
- }
- }
-
ChatDialog dialog;
dialog.show();
return app.exec();
diff --git a/examples/network/network-chat/peermanager.cpp b/examples/network/network-chat/peermanager.cpp
index 5c48edb1b9..2c9d182211 100644
--- a/examples/network/network-chat/peermanager.cpp
+++ b/examples/network/network-chat/peermanager.cpp
@@ -81,12 +81,12 @@ PeerManager::PeerManager(Client *client)
broadcastSocket.bind(QHostAddress::Any, broadcastPort, QUdpSocket::ShareAddress
| QUdpSocket::ReuseAddressHint);
- connect(&broadcastSocket, SIGNAL(readyRead()),
- this, SLOT(readBroadcastDatagram()));
+ connect(&broadcastSocket, &QUdpSocket::readyRead,
+ this, &PeerManager::readBroadcastDatagram);
broadcastTimer.setInterval(BroadcastInterval);
- connect(&broadcastTimer, SIGNAL(timeout()),
- this, SLOT(sendBroadcastDatagram()));
+ connect(&broadcastTimer, &QTimer::timeout,
+ this, &PeerManager::sendBroadcastDatagram);
}
void PeerManager::setServerPort(int port)
diff --git a/examples/network/network-chat/server.h b/examples/network/network-chat/server.h
index d86ed36bce..0a7e6e18c1 100644
--- a/examples/network/network-chat/server.h
+++ b/examples/network/network-chat/server.h
@@ -60,7 +60,7 @@ class Server : public QTcpServer
Q_OBJECT
public:
- Server(QObject *parent = 0);
+ Server(QObject *parent = nullptr);
signals:
void newConnection(Connection *connection);
diff --git a/examples/network/network.pro b/examples/network/network.pro
index 1556e26ab1..3f851d7c71 100644
--- a/examples/network/network.pro
+++ b/examples/network/network.pro
@@ -19,17 +19,13 @@ qtHaveModule(widgets) {
multicastreceiver \
multicastsender
- qtConfig(bearermanagement) {
- qtConfig(processenvironment): SUBDIRS += network-chat
+ qtConfig(processenvironment): SUBDIRS += network-chat
- SUBDIRS += \
- bearermonitor \
- fortuneclient \
- fortuneserver
+ SUBDIRS += \
+ fortuneclient \
+ fortuneserver
- }
-
- qtConfig(openssl): SUBDIRS += securesocketclient
+ qtConfig(ssl): SUBDIRS += securesocketclient
qtConfig(dtls): SUBDIRS += secureudpserver secureudpclient
qtConfig(sctp): SUBDIRS += multistreamserver multistreamclient
}
diff --git a/examples/network/securesocketclient/main.cpp b/examples/network/securesocketclient/main.cpp
index e9c413577f..7cda94cc34 100644
--- a/examples/network/securesocketclient/main.cpp
+++ b/examples/network/securesocketclient/main.cpp
@@ -63,8 +63,8 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
if (!QSslSocket::supportsSsl()) {
- QMessageBox::information(0, "Secure Socket Client",
- "This system does not support SSL/TLS.");
+ QMessageBox::information(nullptr, "Secure Socket Client",
+ "This system does not support TLS.");
return -1;
}
diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp
index 79ed7746d6..d6c52a1c66 100644
--- a/examples/network/securesocketclient/sslclient.cpp
+++ b/examples/network/securesocketclient/sslclient.cpp
@@ -54,8 +54,6 @@
#include "ui_sslclient.h"
#include "ui_sslerrors.h"
-#include <QtCore>
-
SslClient::SslClient(QWidget *parent)
: QWidget(parent)
{
@@ -185,16 +183,17 @@ void SslClient::setupUi()
form->hostNameEdit->setSelection(0, form->hostNameEdit->text().size());
form->sessionOutput->setHtml(tr("&lt;not connected&gt;"));
- connect(form->hostNameEdit, SIGNAL(textChanged(QString)),
- this, SLOT(updateEnabledState()));
- connect(form->connectButton, SIGNAL(clicked()),
- this, SLOT(secureConnect()));
- connect(form->sendButton, SIGNAL(clicked()),
- this, SLOT(sendData()));
+ connect(form->hostNameEdit, &QLineEdit::textChanged,
+ this, &SslClient::updateEnabledState);
+ connect(form->connectButton, &QPushButton::clicked,
+ this, &SslClient::secureConnect);
+ connect(form->sendButton, &QPushButton::clicked,
+ this, &SslClient::sendData);
padLock = new QToolButton;
padLock->setIcon(QIcon(":/encrypted.png"));
- connect(padLock, SIGNAL(clicked()), this, SLOT(displayCertificateInfo()));
+ connect(padLock, &QToolButton::clicked,
+ this, &SslClient::displayCertificateInfo);
#if QT_CONFIG(cursor)
padLock->setCursor(Qt::ArrowCursor);
@@ -223,16 +222,16 @@ void SslClient::setupSecureSocket()
socket = new QSslSocket(this);
- connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
- this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
- connect(socket, SIGNAL(encrypted()),
- this, SLOT(socketEncrypted()));
- connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(socketError(QAbstractSocket::SocketError)));
- connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
- this, SLOT(sslErrors(QList<QSslError>)));
- connect(socket, SIGNAL(readyRead()),
- this, SLOT(socketReadyRead()));
+ connect(socket, &QSslSocket::stateChanged,
+ this, &SslClient::socketStateChanged);
+ connect(socket, &QSslSocket::encrypted,
+ this, &SslClient::socketEncrypted);
+ connect(socket, &QSslSocket::errorOccurred,
+ this, &SslClient::socketError);
+ connect(socket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors),
+ this, &SslClient::sslErrors);
+ connect(socket, &QSslSocket::readyRead,
+ this, &SslClient::socketReadyRead);
}
diff --git a/examples/network/threadedfortuneserver/dialog.cpp b/examples/network/threadedfortuneserver/dialog.cpp
index fcd6655ab9..e5b389f1e6 100644
--- a/examples/network/threadedfortuneserver/dialog.cpp
+++ b/examples/network/threadedfortuneserver/dialog.cpp
@@ -89,7 +89,7 @@ Dialog::Dialog(QWidget *parent)
"Run the Fortune Client example now.")
.arg(ipAddress).arg(server.serverPort()));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(quitButton, &QPushButton::clicked, this, &Dialog::close);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
diff --git a/examples/network/threadedfortuneserver/dialog.h b/examples/network/threadedfortuneserver/dialog.h
index d127b8bfc2..2898c5311c 100644
--- a/examples/network/threadedfortuneserver/dialog.h
+++ b/examples/network/threadedfortuneserver/dialog.h
@@ -64,7 +64,7 @@ class Dialog : public QWidget
Q_OBJECT
public:
- Dialog(QWidget *parent = 0);
+ Dialog(QWidget *parent = nullptr);
private:
QLabel *statusLabel;
diff --git a/examples/network/threadedfortuneserver/fortuneserver.cpp b/examples/network/threadedfortuneserver/fortuneserver.cpp
index 791ffc71f4..73d7e22531 100644
--- a/examples/network/threadedfortuneserver/fortuneserver.cpp
+++ b/examples/network/threadedfortuneserver/fortuneserver.cpp
@@ -74,7 +74,7 @@ void FortuneServer::incomingConnection(qintptr socketDescriptor)
{
QString fortune = fortunes.at(QRandomGenerator::global()->bounded(fortunes.size()));
FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
- connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
+ connect(thread, &FortuneThread::finished, thread, &FortuneThread::deleteLater);
thread->start();
}
//! [1]
diff --git a/examples/network/threadedfortuneserver/fortuneserver.h b/examples/network/threadedfortuneserver/fortuneserver.h
index dc0949bcb2..26ea3d1cbb 100644
--- a/examples/network/threadedfortuneserver/fortuneserver.h
+++ b/examples/network/threadedfortuneserver/fortuneserver.h
@@ -60,7 +60,7 @@ class FortuneServer : public QTcpServer
Q_OBJECT
public:
- FortuneServer(QObject *parent = 0);
+ FortuneServer(QObject *parent = nullptr);
protected:
void incomingConnection(qintptr socketDescriptor) override;
diff --git a/examples/network/torrent/addtorrentdialog.cpp b/examples/network/torrent/addtorrentdialog.cpp
index c87110ac4a..129ad8c968 100644
--- a/examples/network/torrent/addtorrentdialog.cpp
+++ b/examples/network/torrent/addtorrentdialog.cpp
@@ -73,12 +73,12 @@ AddTorrentDialog::AddTorrentDialog(QWidget *parent)
{
ui.setupUi(this);
- connect(ui.browseTorrents, SIGNAL(clicked()),
- this, SLOT(selectTorrent()));
- connect(ui.browseDestination, SIGNAL(clicked()),
- this, SLOT(selectDestination()));
- connect(ui.torrentFile, SIGNAL(textChanged(QString)),
- this, SLOT(setTorrent(QString)));
+ connect(ui.browseTorrents, &QPushButton::clicked,
+ this, &AddTorrentDialog::selectTorrent);
+ connect(ui.browseDestination, &QPushButton::clicked,
+ this, &AddTorrentDialog::selectDestination);
+ connect(ui.torrentFile, &QLineEdit::textChanged,
+ this, &AddTorrentDialog::setTorrent);
ui.destinationFolder->setText(destinationDirectory = QDir::current().path());
ui.torrentFile->setFocus();
diff --git a/examples/network/torrent/addtorrentdialog.h b/examples/network/torrent/addtorrentdialog.h
index b5bd1df84f..00546c624c 100644
--- a/examples/network/torrent/addtorrentdialog.h
+++ b/examples/network/torrent/addtorrentdialog.h
@@ -60,7 +60,7 @@ class AddTorrentDialog : public QDialog
Q_OBJECT
public:
- AddTorrentDialog(QWidget *parent = 0);
+ AddTorrentDialog(QWidget *parent = nullptr);
QString torrentFileName() const;
QString destinationFolder() const;
diff --git a/examples/network/torrent/filemanager.h b/examples/network/torrent/filemanager.h
index 82f9983ea6..1438ed5404 100644
--- a/examples/network/torrent/filemanager.h
+++ b/examples/network/torrent/filemanager.h
@@ -70,7 +70,7 @@ class FileManager : public QThread
Q_OBJECT
public:
- FileManager(QObject *parent = 0);
+ FileManager(QObject *parent = nullptr);
virtual ~FileManager();
inline void setMetaInfo(const MetaInfo &info) { metaInfo = info; }
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp
index 704012ef6d..c343ee81b9 100644
--- a/examples/network/torrent/mainwindow.cpp
+++ b/examples/network/torrent/mainwindow.cpp
@@ -60,7 +60,7 @@ class TorrentView : public QTreeWidget
{
Q_OBJECT
public:
- TorrentView(QWidget *parent = 0);
+ TorrentView(QWidget *parent = nullptr);
#if QT_CONFIG(draganddrop)
signals:
@@ -110,7 +110,7 @@ public:
};
MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent), quitDialog(0), saveChanges(false)
+ : QMainWindow(parent), quitDialog(nullptr), saveChanges(false)
{
// Initialize some static strings
QStringList headers;
@@ -147,12 +147,12 @@ MainWindow::MainWindow(QWidget *parent)
fileMenu->addAction(pauseTorrentAction);
fileMenu->addAction(removeTorrentAction);
fileMenu->addSeparator();
- fileMenu->addAction(QIcon(":/icons/exit.png"), tr("E&xit"), this, SLOT(close()));
+ fileMenu->addAction(QIcon(":/icons/exit.png"), tr("E&xit"), this, &MainWindow::close);
// Help menu
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("&About"), this, SLOT(about()));
- helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
+ helpMenu->addAction(tr("&About"), this, &MainWindow::about);
+ helpMenu->addAction(tr("About &Qt"), qApp, QApplication::aboutQt);
// Top toolbar
QToolBar *topBar = new QToolBar(tr("Tools"));
@@ -183,29 +183,29 @@ MainWindow::MainWindow(QWidget *parent)
bottomBar->addWidget((uploadLimitLabel = new QLabel(tr("0 KB/s"))));
uploadLimitLabel->setFixedSize(QSize(fm.horizontalAdvance(tr("99999 KB/s")), fm.lineSpacing()));
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MACOS
setUnifiedTitleAndToolBarOnMac(true);
#endif
// Set up connections
- connect(torrentView, SIGNAL(itemSelectionChanged()),
- this, SLOT(setActionsEnabled()));
- connect(torrentView, SIGNAL(fileDropped(QString)),
- this, SLOT(acceptFileDrop(QString)));
- connect(uploadLimitSlider, SIGNAL(valueChanged(int)),
- this, SLOT(setUploadLimit(int)));
- connect(downloadLimitSlider, SIGNAL(valueChanged(int)),
- this, SLOT(setDownloadLimit(int)));
- connect(newTorrentAction, SIGNAL(triggered()),
- this, SLOT(addTorrent()));
- connect(pauseTorrentAction, SIGNAL(triggered()),
- this, SLOT(pauseTorrent()));
- connect(removeTorrentAction, SIGNAL(triggered()),
- this, SLOT(removeTorrent()));
- connect(upActionTool, SIGNAL(triggered(bool)),
- this, SLOT(moveTorrentUp()));
- connect(downActionTool, SIGNAL(triggered(bool)),
- this, SLOT(moveTorrentDown()));
+ connect(torrentView, &TorrentView::itemSelectionChanged,
+ this, &MainWindow::setActionsEnabled);
+ connect(torrentView, &TorrentView::fileDropped,
+ this, &MainWindow::acceptFileDrop);
+ connect(uploadLimitSlider, &QSlider::valueChanged,
+ this, &MainWindow::setUploadLimit);
+ connect(downloadLimitSlider, &QSlider::valueChanged,
+ this, &MainWindow::setDownloadLimit);
+ connect(newTorrentAction, &QAction::triggered,
+ this, QOverload<>::of(&MainWindow::addTorrent));
+ connect(pauseTorrentAction, &QAction::triggered,
+ this, &MainWindow::pauseTorrent);
+ connect(removeTorrentAction, &QAction::triggered,
+ this, &MainWindow::removeTorrent);
+ connect(upActionTool, &QAction::triggered,
+ this, &MainWindow::moveTorrentUp);
+ connect(downActionTool, &QAction::triggered,
+ this, &MainWindow::moveTorrentDown);
// Load settings and start
setWindowTitle(tr("Torrent Client"));
@@ -297,7 +297,7 @@ bool MainWindow::addTorrent()
addTorrent(fileName, addTorrentDialog->destinationFolder());
if (!saveChanges) {
saveChanges = true;
- QTimer::singleShot(1000, this, SLOT(saveSettings()));
+ QTimer::singleShot(1000, this, &MainWindow::saveSettings);
}
return true;
}
@@ -311,7 +311,8 @@ void MainWindow::removeTorrent()
// Stop the client.
client->disconnect();
- connect(client, SIGNAL(stopped()), this, SLOT(torrentStopped()));
+ connect(client, &TorrentClient::stopped,
+ this, &MainWindow::torrentStopped);
client->stop();
// Remove the row from the view.
@@ -379,13 +380,20 @@ bool MainWindow::addTorrent(const QString &fileName, const QString &destinationF
client->setDumpedState(resumeState);
// Setup the client connections.
- connect(client, SIGNAL(stateChanged(TorrentClient::State)), this, SLOT(updateState(TorrentClient::State)));
- connect(client, SIGNAL(peerInfoUpdated()), this, SLOT(updatePeerInfo()));
- connect(client, SIGNAL(progressUpdated(int)), this, SLOT(updateProgress(int)));
- connect(client, SIGNAL(downloadRateUpdated(int)), this, SLOT(updateDownloadRate(int)));
- connect(client, SIGNAL(uploadRateUpdated(int)), this, SLOT(updateUploadRate(int)));
- connect(client, SIGNAL(stopped()), this, SLOT(torrentStopped()));
- connect(client, SIGNAL(error(TorrentClient::Error)), this, SLOT(torrentError(TorrentClient::Error)));
+ connect(client, &TorrentClient::stateChanged,
+ this, &MainWindow::updateState);
+ connect(client, &TorrentClient::peerInfoUpdated,
+ this, &MainWindow::updatePeerInfo);
+ connect(client, &TorrentClient::progressUpdated,
+ this, &MainWindow::updateProgress);
+ connect(client, &TorrentClient::downloadRateUpdated,
+ this, &MainWindow::updateDownloadRate);
+ connect(client, &TorrentClient::uploadRateUpdated,
+ this, &MainWindow::updateUploadRate);
+ connect(client, &TorrentClient::stopped,
+ this, &MainWindow::torrentStopped);
+ connect(client, QOverload<TorrentClient::Error>::of(&TorrentClient::error),
+ this, &MainWindow::torrentError);
// Add the client to the list of downloading jobs.
Job job;
@@ -414,7 +422,7 @@ bool MainWindow::addTorrent(const QString &fileName, const QString &destinationF
if (!saveChanges) {
saveChanges = true;
- QTimer::singleShot(5000, this, SLOT(saveSettings()));
+ QTimer::singleShot(5000, this, &MainWindow::saveSettings);
}
client->start();
return true;
@@ -491,15 +499,15 @@ void MainWindow::setActionsEnabled()
{
// Find the view item and client for the current row, and update
// the states of the actions.
- QTreeWidgetItem *item = 0;
+ QTreeWidgetItem *item = nullptr;
if (!torrentView->selectedItems().isEmpty())
item = torrentView->selectedItems().first();
- TorrentClient *client = item ? jobs.at(torrentView->indexOfTopLevelItem(item)).client : 0;
+ TorrentClient *client = item ? jobs.at(torrentView->indexOfTopLevelItem(item)).client : nullptr;
bool pauseEnabled = client && ((client->state() == TorrentClient::Paused)
|| (client->state() > TorrentClient::Preparing));
- removeTorrentAction->setEnabled(item != 0);
- pauseTorrentAction->setEnabled(item != 0 && pauseEnabled);
+ removeTorrentAction->setEnabled(item != nullptr);
+ pauseTorrentAction->setEnabled(item && pauseEnabled);
if (client && client->state() == TorrentClient::Paused) {
pauseTorrentAction->setIcon(QIcon(":/icons/player_play.png"));
@@ -524,7 +532,7 @@ void MainWindow::updateDownloadRate(int bytesPerSecond)
if (!saveChanges) {
saveChanges = true;
- QTimer::singleShot(5000, this, SLOT(saveSettings()));
+ QTimer::singleShot(5000, this, &MainWindow::saveSettings);
}
}
@@ -538,7 +546,7 @@ void MainWindow::updateUploadRate(int bytesPerSecond)
if (!saveChanges) {
saveChanges = true;
- QTimer::singleShot(5000, this, SLOT(saveSettings()));
+ QTimer::singleShot(5000, this, &MainWindow::saveSettings);
}
}
@@ -649,7 +657,7 @@ void MainWindow::about()
about.setWindowTitle(tr("About Torrent Client"));
about.setLayout(mainLayout);
- connect(quitButton, SIGNAL(clicked()), &about, SLOT(close()));
+ connect(quitButton, &QPushButton::clicked, &about, &QDialog::close);
about.exec();
}
@@ -688,7 +696,7 @@ void MainWindow::closeEvent(QCloseEvent *)
++jobsToStop;
TorrentClient *client = job.client;
client->disconnect();
- connect(client, SIGNAL(stopped()), this, SLOT(torrentStopped()));
+ connect(client, &TorrentClient::stopped, this, &MainWindow::torrentStopped);
client->stop();
delete torrentView->takeTopLevelItem(0);
}
@@ -696,7 +704,7 @@ void MainWindow::closeEvent(QCloseEvent *)
if (jobsToStop > jobsStopped)
quitDialog->exec();
quitDialog->deleteLater();
- quitDialog = 0;
+ quitDialog = nullptr;
}
TorrentView::TorrentView(QWidget *parent)
diff --git a/examples/network/torrent/mainwindow.h b/examples/network/torrent/mainwindow.h
index 9c55b72256..78542b535b 100644
--- a/examples/network/torrent/mainwindow.h
+++ b/examples/network/torrent/mainwindow.h
@@ -71,7 +71,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
- MainWindow(QWidget *parent = 0);
+ MainWindow(QWidget *parent = nullptr);
QSize sizeHint() const override;
const TorrentClient *clientForRow(int row) const;
diff --git a/examples/network/torrent/peerwireclient.cpp b/examples/network/torrent/peerwireclient.cpp
index 7a53c85f0c..c30abd0e13 100644
--- a/examples/network/torrent/peerwireclient.cpp
+++ b/examples/network/torrent/peerwireclient.cpp
@@ -87,7 +87,7 @@ PeerWireClient::PeerWireClient(const QByteArray &peerId, QObject *parent)
: QTcpSocket(parent), pendingBlockSizes(0),
pwState(ChokingPeer | ChokedByPeer), receivedHandShake(false), gotPeerId(false),
sentHandShake(false), nextPacketLength(-1), pendingRequestTimer(0), invalidateTimeout(false),
- keepAliveTimer(0), torrentPeer(0)
+ keepAliveTimer(0), torrentPeer(nullptr)
{
memset(uploadSpeedData, 0, sizeof(uploadSpeedData));
memset(downloadSpeedData, 0, sizeof(downloadSpeedData));
@@ -96,21 +96,23 @@ PeerWireClient::PeerWireClient(const QByteArray &peerId, QObject *parent)
timeoutTimer = startTimer(ConnectTimeout);
peerIdString = peerId;
- connect(this, SIGNAL(readyRead()), this, SIGNAL(readyToTransfer()));
- connect(this, SIGNAL(connected()), this, SIGNAL(readyToTransfer()));
-
- connect(&socket, SIGNAL(connected()),
- this, SIGNAL(connected()));
- connect(&socket, SIGNAL(readyRead()),
- this, SIGNAL(readyRead()));
- connect(&socket, SIGNAL(disconnected()),
- this, SIGNAL(disconnected()));
- connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SIGNAL(error(QAbstractSocket::SocketError)));
- connect(&socket, SIGNAL(bytesWritten(qint64)),
- this, SIGNAL(bytesWritten(qint64)));
- connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
- this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
+ connect(this, &PeerWireClient::readyRead,
+ this, &PeerWireClient::readyToTransfer);
+ connect(this, &PeerWireClient::connected,
+ this, &PeerWireClient::readyToTransfer);
+
+ connect(&socket, &QTcpSocket::connected,
+ this, &PeerWireClient::connected);
+ connect(&socket, &QTcpSocket::readyRead,
+ this, &PeerWireClient::readyRead);
+ connect(&socket, &QTcpSocket::disconnected,
+ this, &PeerWireClient::disconnected);
+ connect(&socket, &QTcpSocket::errorOccurred,
+ this, &PeerWireClient::errorOccurred);
+ connect(&socket, &QTcpSocket::bytesWritten,
+ this, &PeerWireClient::bytesWritten);
+ connect(&socket, &QTcpSocket::stateChanged,
+ this, &PeerWireClient::socketStateChanged);
}
diff --git a/examples/network/torrent/peerwireclient.h b/examples/network/torrent/peerwireclient.h
index e03b538f63..75edf8ee77 100644
--- a/examples/network/torrent/peerwireclient.h
+++ b/examples/network/torrent/peerwireclient.h
@@ -92,7 +92,7 @@ public:
};
Q_DECLARE_FLAGS(PeerWireState, PeerWireStateFlag)
- explicit PeerWireClient(const QByteArray &peerId, QObject *parent = 0);
+ explicit PeerWireClient(const QByteArray &peerId, QObject *parent = nullptr);
void initialize(const QByteArray &infoHash, int pieceCount);
void setPeer(TorrentPeer *peer);
diff --git a/examples/network/torrent/ratecontroller.cpp b/examples/network/torrent/ratecontroller.cpp
index 96474806f5..756947b65c 100644
--- a/examples/network/torrent/ratecontroller.cpp
+++ b/examples/network/torrent/ratecontroller.cpp
@@ -62,7 +62,8 @@ RateController *RateController::instance()
void RateController::addSocket(PeerWireClient *socket)
{
- connect(socket, SIGNAL(readyToTransfer()), this, SLOT(scheduleTransfer()));
+ connect(socket, &PeerWireClient::readyToTransfer,
+ this, &RateController::scheduleTransfer);
socket->setReadBufferSize(downLimit * 4);
sockets << socket;
scheduleTransfer();
@@ -70,7 +71,8 @@ void RateController::addSocket(PeerWireClient *socket)
void RateController::removeSocket(PeerWireClient *socket)
{
- disconnect(socket, SIGNAL(readyToTransfer()), this, SLOT(scheduleTransfer()));
+ disconnect(socket, &PeerWireClient::readyToTransfer,
+ this, &RateController::scheduleTransfer);
socket->setReadBufferSize(0);
sockets.remove(socket);
}
diff --git a/examples/network/torrent/ratecontroller.h b/examples/network/torrent/ratecontroller.h
index f8bff0cc36..593a76f592 100644
--- a/examples/network/torrent/ratecontroller.h
+++ b/examples/network/torrent/ratecontroller.h
@@ -62,8 +62,7 @@ class RateController : public QObject
Q_OBJECT
public:
- inline RateController(QObject *parent = 0)
- : QObject(parent), transferScheduled(false) { }
+ using QObject::QObject;
static RateController *instance();
void addSocket(PeerWireClient *socket);
@@ -81,9 +80,9 @@ public slots:
private:
QElapsedTimer stopWatch;
QSet<PeerWireClient *> sockets;
- int upLimit;
- int downLimit;
- bool transferScheduled;
+ int upLimit = 0;
+ int downLimit = 0;
+ bool transferScheduled = false;
};
#endif
diff --git a/examples/network/torrent/torrentclient.cpp b/examples/network/torrent/torrentclient.cpp
index bddf3caa1a..2ba4476861 100644
--- a/examples/network/torrent/torrentclient.cpp
+++ b/examples/network/torrent/torrentclient.cpp
@@ -75,13 +75,12 @@ static const int MinimumTimeBeforeRevisit = 30;
static const int MaxUploads = 4;
static const int UploadScheduleInterval = 10000;
-class TorrentPiece {
-public:
- int index;
- int length;
+struct TorrentPiece {
QBitArray completedBlocks;
QBitArray requestedBlocks;
- bool inProgress;
+ int index = 0;
+ int length = 0;
+ bool inProgress = false;
};
class TorrentClientPrivate
@@ -227,7 +226,7 @@ void TorrentClientPrivate::callPeerConnector()
{
if (!connectingToClients) {
connectingToClients = true;
- QTimer::singleShot(10000, q, SLOT(connectToPeers()));
+ QTimer::singleShot(10000, q, &TorrentClient::connectToPeers);
}
}
@@ -235,22 +234,22 @@ TorrentClient::TorrentClient(QObject *parent)
: QObject(parent), d(new TorrentClientPrivate(this))
{
// Connect the file manager
- connect(&d->fileManager, SIGNAL(dataRead(int,int,int,QByteArray)),
- this, SLOT(sendToPeer(int,int,int,QByteArray)));
- connect(&d->fileManager, SIGNAL(verificationProgress(int)),
- this, SLOT(updateProgress(int)));
- connect(&d->fileManager, SIGNAL(verificationDone()),
- this, SLOT(fullVerificationDone()));
- connect(&d->fileManager, SIGNAL(pieceVerified(int,bool)),
- this, SLOT(pieceVerified(int,bool)));
- connect(&d->fileManager, SIGNAL(error()),
- this, SLOT(handleFileError()));
+ connect(&d->fileManager, &FileManager::dataRead,
+ this, &TorrentClient::sendToPeer);
+ connect(&d->fileManager, &FileManager::verificationProgress,
+ this, &TorrentClient::updateProgress);
+ connect(&d->fileManager, &FileManager::verificationDone,
+ this, &TorrentClient::fullVerificationDone);
+ connect(&d->fileManager, &FileManager::pieceVerified,
+ this, &TorrentClient::pieceVerified);
+ connect(&d->fileManager, &FileManager::error,
+ this, &TorrentClient::handleFileError);
// Connect the tracker client
- connect(&d->trackerClient, SIGNAL(peerListUpdated(QList<TorrentPeer>)),
- this, SLOT(addToPeerList(QList<TorrentPeer>)));
- connect(&d->trackerClient, SIGNAL(stopped()),
- this, SIGNAL(stopped()));
+ connect(&d->trackerClient, &TrackerClient::peerListUpdated,
+ this, &TorrentClient::addToPeerList);
+ connect(&d->trackerClient, &TrackerClient::stopped,
+ this, &TorrentClient::stopped);
}
TorrentClient::~TorrentClient()
@@ -840,26 +839,26 @@ void TorrentClient::setupOutgoingConnection()
void TorrentClient::initializeConnection(PeerWireClient *client)
{
- connect(client, SIGNAL(connected()),
- this, SLOT(setupOutgoingConnection()));
- connect(client, SIGNAL(disconnected()),
- this, SLOT(removeClient()));
- connect(client, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(removeClient()));
- connect(client, SIGNAL(piecesAvailable(QBitArray)),
- this, SLOT(peerPiecesAvailable(QBitArray)));
- connect(client, SIGNAL(blockRequested(int,int,int)),
- this, SLOT(peerRequestsBlock(int,int,int)));
- connect(client, SIGNAL(blockReceived(int,int,QByteArray)),
- this, SLOT(blockReceived(int,int,QByteArray)));
- connect(client, SIGNAL(choked()),
- this, SLOT(peerChoked()));
- connect(client, SIGNAL(unchoked()),
- this, SLOT(peerUnchoked()));
- connect(client, SIGNAL(bytesWritten(qint64)),
- this, SLOT(peerWireBytesWritten(qint64)));
- connect(client, SIGNAL(bytesReceived(qint64)),
- this, SLOT(peerWireBytesReceived(qint64)));
+ connect(client, &PeerWireClient::connected,
+ this, &TorrentClient::setupOutgoingConnection);
+ connect(client, &PeerWireClient::disconnected,
+ this, &TorrentClient::removeClient);
+ connect(client, &PeerWireClient::errorOccurred,
+ this, &TorrentClient::removeClient);
+ connect(client, &PeerWireClient::piecesAvailable,
+ this, &TorrentClient::peerPiecesAvailable);
+ connect(client, &PeerWireClient::blockRequested,
+ this, &TorrentClient::peerRequestsBlock);
+ connect(client, &PeerWireClient::blockReceived,
+ this, &TorrentClient::blockReceived);
+ connect(client, &PeerWireClient::choked,
+ this, &TorrentClient::peerChoked);
+ connect(client, &PeerWireClient::unchoked,
+ this, &TorrentClient::peerUnchoked);
+ connect(client, &PeerWireClient::bytesWritten,
+ this, &TorrentClient::peerWireBytesWritten);
+ connect(client, &PeerWireClient::bytesReceived,
+ this, &TorrentClient::peerWireBytesReceived);
}
void TorrentClient::removeClient()
@@ -890,7 +889,8 @@ void TorrentClient::removeClient()
}
// Delete the client later.
- disconnect(client, SIGNAL(disconnected()), this, SLOT(removeClient()));
+ disconnect(client, &PeerWireClient::disconnected,
+ this, &TorrentClient::removeClient);
client->deleteLater();
ConnectionManager::instance()->removeConnection(client);
@@ -905,7 +905,7 @@ void TorrentClient::peerPiecesAvailable(const QBitArray &pieces)
// Find the peer in our list of announced peers. If it's there,
// then we can use the piece list into to gather statistics that
// help us decide what peers to connect to.
- TorrentPeer *peer = 0;
+ TorrentPeer *peer = nullptr;
QList<TorrentPeer *>::Iterator it = d->peers.begin();
while (it != d->peers.end()) {
if ((*it)->address == client->peerAddress() && (*it)->port == client->peerPort()) {
@@ -1163,7 +1163,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
// many blocks have been requested.
QList<int> currentPieces;
bool somePiecesAreNotInProgress = false;
- TorrentPiece *lastPendingPiece = 0;
+ TorrentPiece *lastPendingPiece = nullptr;
QMultiMap<PeerWireClient *, TorrentPiece *>::Iterator it = d->payloads.find(client);
while (it != d->payloads.end() && it.key() == client) {
lastPendingPiece = it.value();
@@ -1183,7 +1183,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
// If all pieces are in progress, but we haven't filled up our
// block requesting quota, then we need to schedule another piece.
if (!somePiecesAreNotInProgress || client->incomingBlocks().size() > 0)
- lastPendingPiece = 0;
+ lastPendingPiece = nullptr;
TorrentPiece *piece = lastPendingPiece;
// In warmup state, all clients request blocks from the same pieces.
diff --git a/examples/network/torrent/torrentclient.h b/examples/network/torrent/torrentclient.h
index b9b88b3a07..ad77caa66c 100644
--- a/examples/network/torrent/torrentclient.h
+++ b/examples/network/torrent/torrentclient.h
@@ -58,8 +58,7 @@
class MetaInfo;
class PeerWireClient;
class TorrentClientPrivate;
-class TorrentPeer;
-class TorrentPiece;
+struct TorrentPiece;
QT_BEGIN_NAMESPACE
class QTimerEvent;
QT_END_NAMESPACE
@@ -110,7 +109,7 @@ public:
ServerError
};
- TorrentClient(QObject *parent = 0);
+ TorrentClient(QObject *parent = nullptr);
~TorrentClient();
bool setTorrent(const QString &fileName);
diff --git a/examples/network/torrent/torrentserver.cpp b/examples/network/torrent/torrentserver.cpp
index c68f33249c..7af958c27c 100644
--- a/examples/network/torrent/torrentserver.cpp
+++ b/examples/network/torrent/torrentserver.cpp
@@ -78,10 +78,10 @@ void TorrentServer::incomingConnection(qintptr socketDescriptor)
if (client->setSocketDescriptor(socketDescriptor)) {
if (ConnectionManager::instance()->canAddConnection() && !clients.isEmpty()) {
- connect(client, SIGNAL(infoHashReceived(QByteArray)),
- this, SLOT(processInfoHash(QByteArray)));
- connect(client, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(removeClient()));
+ connect(client, &PeerWireClient::infoHashReceived,
+ this, &TorrentServer::processInfoHash);
+ connect(client, &PeerWireClient::errorOccurred,
+ this, QOverload<>::of(&TorrentServer::removeClient));
RateController::instance()->addSocket(client);
ConnectionManager::instance()->addConnection(client);
return;
@@ -104,7 +104,7 @@ void TorrentServer::processInfoHash(const QByteArray &infoHash)
PeerWireClient *peer = qobject_cast<PeerWireClient *>(sender());
for (TorrentClient *client : qAsConst(clients)) {
if (client->state() >= TorrentClient::Searching && client->infoHash() == infoHash) {
- peer->disconnect(peer, 0, this, 0);
+ peer->disconnect(peer, nullptr, this, nullptr);
client->setupIncomingConnection(peer);
return;
}
diff --git a/examples/network/torrent/trackerclient.cpp b/examples/network/torrent/trackerclient.cpp
index e883317b12..264a6cc04c 100644
--- a/examples/network/torrent/trackerclient.cpp
+++ b/examples/network/torrent/trackerclient.cpp
@@ -60,14 +60,8 @@
TrackerClient::TrackerClient(TorrentClient *downloader, QObject *parent)
: QObject(parent), torrentDownloader(downloader)
{
- length = 0;
- requestInterval = 5 * 60;
- requestIntervalTimer = -1;
- firstTrackerRequest = true;
- lastTrackerRequest = false;
- firstSeeding = true;
-
- connect(&http, SIGNAL(finished(QNetworkReply*)), this, SLOT(httpRequestDone(QNetworkReply*)));
+ connect(&http, &QNetworkAccessManager::finished,
+ this, &TrackerClient::httpRequestDone);
}
void TrackerClient::start(const MetaInfo &info)
@@ -157,8 +151,8 @@ void TrackerClient::fetchPeerList()
if (!url.userName().isEmpty()) {
uname = url.userName();
pwd = url.password();
- connect(&http, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
- this, SLOT(provideAuthentication(QNetworkReply*,QAuthenticator*)));
+ connect(&http, &QNetworkAccessManager::authenticationRequired,
+ this, &TrackerClient::provideAuthentication);
}
http.get(req);
}
@@ -215,7 +209,7 @@ void TrackerClient::httpRequestDone(QNetworkReply *reply)
// store it
peers.clear();
QVariant peerEntry = dict.value("peers");
- if (peerEntry.type() == QVariant::List) {
+ if (peerEntry.userType() == QMetaType::QVariantList) {
QList<QVariant> peerTmp = peerEntry.toList();
for (int i = 0; i < peerTmp.size(); ++i) {
TorrentPeer tmp;
diff --git a/examples/network/torrent/trackerclient.h b/examples/network/torrent/trackerclient.h
index 323fc67eba..b8c169ff22 100644
--- a/examples/network/torrent/trackerclient.h
+++ b/examples/network/torrent/trackerclient.h
@@ -69,7 +69,7 @@ class TrackerClient : public QObject
Q_OBJECT
public:
- explicit TrackerClient(TorrentClient *downloader, QObject *parent = 0);
+ explicit TrackerClient(TorrentClient *downloader, QObject *parent = nullptr);
void start(const MetaInfo &info);
void stop();
@@ -98,21 +98,19 @@ private slots:
private:
TorrentClient *torrentDownloader;
- int requestInterval;
- int requestIntervalTimer;
+ int requestInterval = 5 * 60;
+ int requestIntervalTimer = -1;
QNetworkAccessManager http;
MetaInfo metaInfo;
QByteArray trackerId;
QList<TorrentPeer> peers;
- qint64 uploadedBytes;
- qint64 downloadedBytes;
- qint64 length;
+ qint64 length = 0;
QString uname;
QString pwd;
- bool firstTrackerRequest;
- bool lastTrackerRequest;
- bool firstSeeding;
+ bool firstTrackerRequest = true;
+ bool lastTrackerRequest = false;
+ bool firstSeeding = true;
};
#endif
diff --git a/examples/opengl/computegles31/glwindow.cpp b/examples/opengl/computegles31/glwindow.cpp
index 29ec9fcff7..5e8d45da24 100644
--- a/examples/opengl/computegles31/glwindow.cpp
+++ b/examples/opengl/computegles31/glwindow.cpp
@@ -73,15 +73,6 @@
#endif
GLWindow::GLWindow()
- : m_texImageInput(0),
- m_texImageTmp(0),
- m_texImageProcessed(0),
- m_shaderDisplay(0),
- m_shaderComputeV(0),
- m_shaderComputeH(0),
- m_blurRadius(0.0f),
- m_animate(true),
- m_vao(0)
{
const float animationStart = 0.0;
const float animationEnd = 10.0;
@@ -324,27 +315,18 @@ void GLWindow::initializeGL()
<< ((ctx->format().renderableType() == QSurfaceFormat::OpenGLES) ? (" GLES") : (" GL"))
<< " context";
- if (m_texImageInput) {
- delete m_texImageInput;
- m_texImageInput = 0;
- }
QImage img(":/Qt-logo-medium.png");
Q_ASSERT(!img.isNull());
+ delete m_texImageInput;
m_texImageInput = new QOpenGLTexture(img.convertToFormat(QImage::Format_RGBA8888).mirrored());
- if (m_texImageTmp) {
- delete m_texImageTmp;
- m_texImageTmp = 0;
- }
+ delete m_texImageTmp;
m_texImageTmp = new QOpenGLTexture(QOpenGLTexture::Target2D);
m_texImageTmp->setFormat(m_texImageInput->format());
m_texImageTmp->setSize(m_texImageInput->width(),m_texImageInput->height());
m_texImageTmp->allocateStorage(QOpenGLTexture::RGBA,QOpenGLTexture::UInt8); // WTF?
- if (m_texImageProcessed) {
- delete m_texImageProcessed;
- m_texImageProcessed = 0;
- }
+ delete m_texImageProcessed;
m_texImageProcessed = new QOpenGLTexture(QOpenGLTexture::Target2D);
m_texImageProcessed->setFormat(m_texImageInput->format());
m_texImageProcessed->setSize(m_texImageInput->width(),m_texImageInput->height());
@@ -354,10 +336,7 @@ void GLWindow::initializeGL()
m_texImageProcessed->setMinificationFilter(QOpenGLTexture::Linear);
m_texImageProcessed->setWrapMode(QOpenGLTexture::ClampToEdge);
- if (m_shaderDisplay) {
- delete m_shaderDisplay;
- m_shaderDisplay = 0;
- }
+ delete m_shaderDisplay;
m_shaderDisplay = new QOpenGLShaderProgram;
// Prepend the correct version directive to the sources. The rest is the
// same, thanks to the common GLSL syntax.
@@ -365,18 +344,12 @@ void GLWindow::initializeGL()
m_shaderDisplay->addShaderFromSourceCode(QOpenGLShader::Fragment, versionedShaderCode(fsDisplaySource));
m_shaderDisplay->link();
- if (m_shaderComputeV) {
- delete m_shaderComputeV;
- m_shaderComputeV = 0;
- }
+ delete m_shaderComputeV;
m_shaderComputeV = new QOpenGLShaderProgram;
m_shaderComputeV->addShaderFromSourceCode(QOpenGLShader::Compute, versionedShaderCode(csComputeSourceV));
m_shaderComputeV->link();
- if (m_shaderComputeH) {
- delete m_shaderComputeH;
- m_shaderComputeH = 0;
- }
+ delete m_shaderComputeH;
m_shaderComputeH = new QOpenGLShaderProgram;
m_shaderComputeH->addShaderFromSourceCode(QOpenGLShader::Compute, versionedShaderCode(csComputeSourceH));
m_shaderComputeH->link();
diff --git a/examples/opengl/computegles31/glwindow.h b/examples/opengl/computegles31/glwindow.h
index f243858a45..5375fbb488 100644
--- a/examples/opengl/computegles31/glwindow.h
+++ b/examples/opengl/computegles31/glwindow.h
@@ -90,21 +90,21 @@ protected:
void setAnimating(bool animate);
private:
- QPropertyAnimation *m_animationForward;
- QPropertyAnimation *m_animationBackward;
+ QPropertyAnimation *m_animationForward = nullptr;
+ QPropertyAnimation *m_animationBackward = nullptr;
QSequentialAnimationGroup *m_animationGroup;
- QOpenGLTexture *m_texImageInput;
- QOpenGLTexture *m_texImageTmp;
- QOpenGLTexture *m_texImageProcessed;
- QOpenGLShaderProgram *m_shaderDisplay;
- QOpenGLShaderProgram *m_shaderComputeV;
- QOpenGLShaderProgram *m_shaderComputeH;
+ QOpenGLTexture *m_texImageInput = nullptr;
+ QOpenGLTexture *m_texImageTmp = nullptr;
+ QOpenGLTexture *m_texImageProcessed = nullptr;
+ QOpenGLShaderProgram *m_shaderDisplay = nullptr;
+ QOpenGLShaderProgram *m_shaderComputeV = nullptr;
+ QOpenGLShaderProgram *m_shaderComputeH = nullptr;
QMatrix4x4 m_proj;
QSizeF m_quadSize;
- int m_blurRadius;
- bool m_animate;
- QOpenGLVertexArrayObject *m_vao;
+ int m_blurRadius = 0;
+ bool m_animate = true;
+ QOpenGLVertexArrayObject *m_vao = nullptr;
};
#endif
diff --git a/examples/opengl/contextinfo/renderwindow.cpp b/examples/opengl/contextinfo/renderwindow.cpp
index 21b7434be6..ea9a7a24cb 100644
--- a/examples/opengl/contextinfo/renderwindow.cpp
+++ b/examples/opengl/contextinfo/renderwindow.cpp
@@ -56,7 +56,7 @@
#include <QOpenGLFunctions>
RenderWindow::RenderWindow(const QSurfaceFormat &format)
- : m_context(0),
+ : m_context(nullptr),
m_initialized(false),
m_forceGLSL110(false),
m_angle(0.0f)
@@ -67,7 +67,7 @@ RenderWindow::RenderWindow(const QSurfaceFormat &format)
m_context->setFormat(requestedFormat());
if (!m_context->create()) {
delete m_context;
- m_context = 0;
+ m_context = nullptr;
}
}
diff --git a/examples/opengl/contextinfo/widget.h b/examples/opengl/contextinfo/widget.h
index 72abe0e647..85d181a229 100644
--- a/examples/opengl/contextinfo/widget.h
+++ b/examples/opengl/contextinfo/widget.h
@@ -64,7 +64,7 @@ class Widget : public QWidget
Q_OBJECT
public:
- explicit Widget(QWidget *parent = 0);
+ explicit Widget(QWidget *parent = nullptr);
private slots:
void start();
diff --git a/examples/opengl/cube/geometryengine.cpp b/examples/opengl/cube/geometryengine.cpp
index 1f9e16a935..24e014201e 100644
--- a/examples/opengl/cube/geometryengine.cpp
+++ b/examples/opengl/cube/geometryengine.cpp
@@ -174,6 +174,6 @@ void GeometryEngine::drawCubeGeometry(QOpenGLShaderProgram *program)
program->setAttributeBuffer(texcoordLocation, GL_FLOAT, offset, 2, sizeof(VertexData));
// Draw cube geometry using indices from VBO 1
- glDrawElements(GL_TRIANGLE_STRIP, 34, GL_UNSIGNED_SHORT, 0);
+ glDrawElements(GL_TRIANGLE_STRIP, 34, GL_UNSIGNED_SHORT, nullptr);
}
//! [2]
diff --git a/examples/opengl/cube/mainwidget.cpp b/examples/opengl/cube/mainwidget.cpp
index 292a4245fa..558ecd1299 100644
--- a/examples/opengl/cube/mainwidget.cpp
+++ b/examples/opengl/cube/mainwidget.cpp
@@ -52,15 +52,7 @@
#include <QMouseEvent>
-#include <math.h>
-
-MainWidget::MainWidget(QWidget *parent) :
- QOpenGLWidget(parent),
- geometries(0),
- texture(0),
- angularSpeed(0)
-{
-}
+#include <cmath>
MainWidget::~MainWidget()
{
diff --git a/examples/opengl/cube/mainwidget.h b/examples/opengl/cube/mainwidget.h
index cd2f8098ad..b6a03d454a 100644
--- a/examples/opengl/cube/mainwidget.h
+++ b/examples/opengl/cube/mainwidget.h
@@ -69,7 +69,7 @@ class MainWidget : public QOpenGLWidget, protected QOpenGLFunctions
Q_OBJECT
public:
- explicit MainWidget(QWidget *parent = 0);
+ using QOpenGLWidget::QOpenGLWidget;
~MainWidget();
protected:
@@ -87,15 +87,15 @@ protected:
private:
QBasicTimer timer;
QOpenGLShaderProgram program;
- GeometryEngine *geometries;
+ GeometryEngine *geometries = nullptr;
- QOpenGLTexture *texture;
+ QOpenGLTexture *texture = nullptr;
QMatrix4x4 projection;
QVector2D mousePressPosition;
QVector3D rotationAxis;
- qreal angularSpeed;
+ qreal angularSpeed = 0;
QQuaternion rotation;
};
diff --git a/examples/opengl/doc/src/2dpainting.qdoc b/examples/opengl/doc/src/2dpainting.qdoc
index e6b33e2a14..d39ae1d7ba 100644
--- a/examples/opengl/doc/src/2dpainting.qdoc
+++ b/examples/opengl/doc/src/2dpainting.qdoc
@@ -30,8 +30,8 @@
\title 2D Painting Example
\ingroup examples-widgets-opengl
- \brief The 2D Painting example shows how QPainter and QGLWidget can be used
- together to display accelerated 2D graphics on supported hardware.
+ \brief The 2D Painting example shows how QPainter and QOpenGLWidget can be
+ used together to display accelerated 2D graphics on supported hardware.
\image 2dpainting-example.png
@@ -39,23 +39,23 @@
paint devices provided by QPaintDevice subclasses, such as QWidget
and QImage.
- Since QGLWidget is a subclass of QWidget, it is possible
+ Since QOpenGLWidget is a subclass of QWidget, it is possible
to reimplement its \l{QWidget::paintEvent()}{paintEvent()} and use
QPainter to draw on the device, just as you would with a QWidget.
The only difference is that the painting operations will be accelerated
in hardware if it is supported by your system's OpenGL drivers.
In this example, we perform the same painting operations on a
- QWidget and a QGLWidget. The QWidget is shown with anti-aliasing
- enabled, and the QGLWidget will also use anti-aliasing if the
+ QWidget and a QOpenGLWidget. The QWidget is shown with anti-aliasing
+ enabled, and the QOpenGLWidget will also use anti-aliasing if the
required extensions are supported by your system's OpenGL driver.
\section1 Overview
- To be able to compare the results of painting onto a QGLWidget subclass
+ To be able to compare the results of painting onto a QOpenGLWidget subclass
with native drawing in a QWidget subclass, we want to show both kinds
of widget side by side. To do this, we derive subclasses of QWidget and
- QGLWidget, using a separate \c Helper class to perform the same painting
+ QOpenGLWidget, using a separate \c Helper class to perform the same painting
operations for each, and lay them out in a top-level widget, itself
provided a the \c Window class.
@@ -63,7 +63,7 @@
In this example, the painting operations are performed by a helper class.
We do this because we want the same painting operations to be performed
- for both our QWidget subclass and the QGLWidget subclass.
+ for both our QWidget subclass and the QOpenGLWidget subclass.
The \c Helper class is minimal:
@@ -81,7 +81,7 @@
The actual painting is performed in the \c paint() function. This takes
a QPainter that has already been set up to paint onto a paint device
- (either a QWidget or a QGLWidget), a QPaintEvent that provides information
+ (either a QWidget or a QOpenGLWidget), a QPaintEvent that provides information
about the region to be painted, and a measure of the elapsed time (in
milliseconds) since the paint device was last updated.
@@ -148,7 +148,7 @@
\section1 GLWidget Class Definition
The \c GLWidget class definition is basically the same as the \c Widget
- class except that it is derived from QGLWidget.
+ class except that it is derived from QOpenGLWidget.
\snippet 2dpainting/glwidget.h 0
diff --git a/examples/opengl/doc/src/cube.qdoc b/examples/opengl/doc/src/cube.qdoc
index 1fdfe0c6ec..d58b8d8020 100644
--- a/examples/opengl/doc/src/cube.qdoc
+++ b/examples/opengl/doc/src/cube.qdoc
@@ -47,7 +47,7 @@
The example consist of two classes:
\list
- \li \c MainWidget extends QGLWidget and contains OpenGL ES 2.0
+ \li \c MainWidget extends QOpenGLWidget and contains OpenGL ES 2.0
initialization and drawing and mouse and timer event handling
\li \c GeometryEngine handles polygon geometries. Transfers polygon geometry
to vertex buffer objects and draws geometries from vertex buffer objects.
@@ -92,7 +92,7 @@
\section1 Loading Textures from Qt Resource Files
- \c QGLWidget interface implements methods for loading textures from QImage to GL
+ \c QOpenGLWidget interface implements methods for loading textures from QImage to GL
texture memory. We still need to use OpenGL provided functions for specifying
the GL texture unit and configuring texture filtering options.
diff --git a/examples/opengl/hellogl2/glwidget.cpp b/examples/opengl/hellogl2/glwidget.cpp
index 318adb5043..543e70f8ac 100644
--- a/examples/opengl/hellogl2/glwidget.cpp
+++ b/examples/opengl/hellogl2/glwidget.cpp
@@ -57,11 +57,7 @@
bool GLWidget::m_transparent = false;
GLWidget::GLWidget(QWidget *parent)
- : QOpenGLWidget(parent),
- m_xRot(0),
- m_yRot(0),
- m_zRot(0),
- m_program(0)
+ : QOpenGLWidget(parent)
{
m_core = QSurfaceFormat::defaultFormat().profile() == QSurfaceFormat::CoreProfile;
// --transparent causes the clear color to be transparent. Therefore, on systems that
@@ -133,7 +129,7 @@ void GLWidget::cleanup()
makeCurrent();
m_logoVbo.destroy();
delete m_program;
- m_program = 0;
+ m_program = nullptr;
doneCurrent();
}
@@ -250,8 +246,10 @@ void GLWidget::setupVertexAttribs()
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0);
f->glEnableVertexAttribArray(1);
- f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), 0);
- f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), reinterpret_cast<void *>(3 * sizeof(GLfloat)));
+ f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat),
+ nullptr);
+ f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat),
+ reinterpret_cast<void *>(3 * sizeof(GLfloat)));
m_logoVbo.release();
}
diff --git a/examples/opengl/hellogl2/glwidget.h b/examples/opengl/hellogl2/glwidget.h
index 21dd200dc7..f8526fb7ae 100644
--- a/examples/opengl/hellogl2/glwidget.h
+++ b/examples/opengl/hellogl2/glwidget.h
@@ -65,7 +65,7 @@ class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
Q_OBJECT
public:
- GLWidget(QWidget *parent = 0);
+ GLWidget(QWidget *parent = nullptr);
~GLWidget();
static bool isTransparent() { return m_transparent; }
@@ -96,18 +96,18 @@ private:
void setupVertexAttribs();
bool m_core;
- int m_xRot;
- int m_yRot;
- int m_zRot;
+ int m_xRot = 0;
+ int m_yRot = 0;
+ int m_zRot = 0;
QPoint m_lastPos;
Logo m_logo;
QOpenGLVertexArrayObject m_vao;
QOpenGLBuffer m_logoVbo;
- QOpenGLShaderProgram *m_program;
- int m_projMatrixLoc;
- int m_mvMatrixLoc;
- int m_normalMatrixLoc;
- int m_lightPosLoc;
+ QOpenGLShaderProgram *m_program = nullptr;
+ int m_projMatrixLoc = 0;
+ int m_mvMatrixLoc = 0;
+ int m_normalMatrixLoc = 0;
+ int m_lightPosLoc = 0;
QMatrix4x4 m_proj;
QMatrix4x4 m_camera;
QMatrix4x4 m_world;
diff --git a/examples/opengl/hellogl2/logo.cpp b/examples/opengl/hellogl2/logo.cpp
index a1ec8eaebe..6fcece16d4 100644
--- a/examples/opengl/hellogl2/logo.cpp
+++ b/examples/opengl/hellogl2/logo.cpp
@@ -52,7 +52,6 @@
#include <qmath.h>
Logo::Logo()
- : m_count(0)
{
m_data.resize(2500 * 6);
diff --git a/examples/opengl/hellogl2/logo.h b/examples/opengl/hellogl2/logo.h
index 9e04a57e86..2f3dc7e649 100644
--- a/examples/opengl/hellogl2/logo.h
+++ b/examples/opengl/hellogl2/logo.h
@@ -69,7 +69,7 @@ private:
void add(const QVector3D &v, const QVector3D &n);
QVector<GLfloat> m_data;
- int m_count;
+ int m_count = 0;
};
#endif // LOGO_H
diff --git a/examples/opengl/hellogl2/mainwindow.cpp b/examples/opengl/hellogl2/mainwindow.cpp
index 6bfdee7785..aa20cd678c 100644
--- a/examples/opengl/hellogl2/mainwindow.cpp
+++ b/examples/opengl/hellogl2/mainwindow.cpp
@@ -72,5 +72,6 @@ void MainWindow::onAddNew()
if (!centralWidget())
setCentralWidget(new Window(this));
else
- QMessageBox::information(0, tr("Cannot add new window"), tr("Already occupied. Undock first."));
+ QMessageBox::information(nullptr, tr("Cannot add new window"),
+ tr("Already occupied. Undock first."));
}
diff --git a/examples/opengl/hellogl2/window.cpp b/examples/opengl/hellogl2/window.cpp
index c3cd10cbfd..5534f2edea 100644
--- a/examples/opengl/hellogl2/window.cpp
+++ b/examples/opengl/hellogl2/window.cpp
@@ -121,7 +121,7 @@ void Window::keyPressEvent(QKeyEvent *e)
void Window::dockUndock()
{
if (parent()) {
- setParent(0);
+ setParent(nullptr);
setAttribute(Qt::WA_DeleteOnClose);
move(QApplication::desktop()->width() / 2 - width() / 2,
QApplication::desktop()->height() / 2 - height() / 2);
@@ -134,10 +134,12 @@ void Window::dockUndock()
dockBtn->setText(tr("Undock"));
mainWindow->setCentralWidget(this);
} else {
- QMessageBox::information(0, tr("Cannot dock"), tr("Main window already closed"));
+ QMessageBox::information(nullptr, tr("Cannot dock"),
+ tr("Main window already closed"));
}
} else {
- QMessageBox::information(0, tr("Cannot dock"), tr("Main window already occupied"));
+ QMessageBox::information(nullptr, tr("Cannot dock"),
+ tr("Main window already occupied"));
}
}
}
diff --git a/examples/opengl/hellogles3/glwindow.cpp b/examples/opengl/hellogles3/glwindow.cpp
index 9458b74810..c644faa9a6 100644
--- a/examples/opengl/hellogles3/glwindow.cpp
+++ b/examples/opengl/hellogles3/glwindow.cpp
@@ -57,19 +57,10 @@
#include <QOpenGLVertexArrayObject>
#include <QOpenGLExtraFunctions>
#include <QPropertyAnimation>
-#include <QPauseAnimation>
#include <QSequentialAnimationGroup>
#include <QTimer>
GLWindow::GLWindow()
- : m_texture(0),
- m_program(0),
- m_vbo(0),
- m_vao(0),
- m_target(0, 0, -1),
- m_uniformsDirty(true),
- m_r(0),
- m_r2(0)
{
m_world.setToIdentity();
m_world.translate(0, 0, -1);
@@ -197,18 +188,12 @@ void GLWindow::initializeGL()
{
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
- if (m_texture) {
- delete m_texture;
- m_texture = 0;
- }
QImage img(":/qtlogo.png");
Q_ASSERT(!img.isNull());
+ delete m_texture;
m_texture = new QOpenGLTexture(img.scaled(32, 36).mirrored());
- if (m_program) {
- delete m_program;
- m_program = 0;
- }
+ delete m_program;
m_program = new QOpenGLShaderProgram;
// Prepend the correct version directive to the sources. The rest is the
// same, thanks to the common GLSL syntax.
@@ -223,26 +208,21 @@ void GLWindow::initializeGL()
m_lightPosLoc = m_program->uniformLocation("lightPos");
// Create a VAO. Not strictly required for ES 3, but it is for plain OpenGL.
- if (m_vao) {
- delete m_vao;
- m_vao = 0;
- }
+ delete m_vao;
m_vao = new QOpenGLVertexArrayObject;
if (m_vao->create())
m_vao->bind();
- if (m_vbo) {
- delete m_vbo;
- m_vbo = 0;
- }
m_program->bind();
+ delete m_vbo;
m_vbo = new QOpenGLBuffer;
m_vbo->create();
m_vbo->bind();
m_vbo->allocate(m_logo.constData(), m_logo.count() * sizeof(GLfloat));
f->glEnableVertexAttribArray(0);
f->glEnableVertexAttribArray(1);
- f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), 0);
+ f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat),
+ nullptr);
f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat),
reinterpret_cast<void *>(3 * sizeof(GLfloat)));
m_vbo->release();
diff --git a/examples/opengl/hellogles3/glwindow.h b/examples/opengl/hellogles3/glwindow.h
index fba997bee4..dfa0680714 100644
--- a/examples/opengl/hellogles3/glwindow.h
+++ b/examples/opengl/hellogles3/glwindow.h
@@ -90,23 +90,23 @@ public:
private slots:
void startSecondStage();
private:
- QOpenGLTexture *m_texture;
- QOpenGLShaderProgram *m_program;
- QOpenGLBuffer *m_vbo;
- QOpenGLVertexArrayObject *m_vao;
+ QOpenGLTexture *m_texture = nullptr;
+ QOpenGLShaderProgram *m_program = nullptr;
+ QOpenGLBuffer *m_vbo = nullptr;
+ QOpenGLVertexArrayObject *m_vao = nullptr;
Logo m_logo;
- int m_projMatrixLoc;
- int m_camMatrixLoc;
- int m_worldMatrixLoc;
- int m_myMatrixLoc;
- int m_lightPosLoc;
+ int m_projMatrixLoc = 0;
+ int m_camMatrixLoc = 0;
+ int m_worldMatrixLoc = 0;
+ int m_myMatrixLoc = 0;
+ int m_lightPosLoc = 0;
QMatrix4x4 m_proj;
QMatrix4x4 m_world;
QVector3D m_eye;
- QVector3D m_target;
- bool m_uniformsDirty;
- float m_r;
- float m_r2;
+ QVector3D m_target = {0, 0, -1};
+ bool m_uniformsDirty = true;
+ float m_r = 0;
+ float m_r2 = 0;
};
#endif
diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp
index 799431a765..94aa215288 100644
--- a/examples/opengl/paintedwindow/paintedwindow.cpp
+++ b/examples/opengl/paintedwindow/paintedwindow.cpp
@@ -54,6 +54,7 @@
#include <QOpenGLContext>
#include <QOpenGLPaintDevice>
#include <QPainter>
+#include <QPainterPath>
#include <QScreen>
#include <QTimer>
diff --git a/examples/opengl/qopenglwidget/bubble.cpp b/examples/opengl/qopenglwidget/bubble.cpp
index dbaf460f6f..7e69aac3e7 100644
--- a/examples/opengl/qopenglwidget/bubble.cpp
+++ b/examples/opengl/qopenglwidget/bubble.cpp
@@ -57,15 +57,13 @@ Bubble::Bubble(const QPointF &position, qreal radius, const QPointF &velocity)
{
innerColor = randomColor();
outerColor = randomColor();
- cache = 0;
updateBrush();
}
//! [0]
void Bubble::updateCache()
{
- if (cache)
- delete cache;
+ delete cache;
cache = new QImage(qRound(radius * 2 + 2), qRound(radius * 2 + 2), QImage::Format_ARGB32_Premultiplied);
cache->fill(0x00000000);
QPainter p(cache);
@@ -80,8 +78,7 @@ void Bubble::updateCache()
Bubble::~Bubble()
{
- if (cache)
- delete cache;
+ delete cache;
}
void Bubble::updateBrush()
diff --git a/examples/opengl/qopenglwidget/bubble.h b/examples/opengl/qopenglwidget/bubble.h
index 7170803b40..833ea02288 100644
--- a/examples/opengl/qopenglwidget/bubble.h
+++ b/examples/opengl/qopenglwidget/bubble.h
@@ -80,7 +80,7 @@ private:
qreal radius;
QColor innerColor;
QColor outerColor;
- QImage *cache;
+ QImage *cache = nullptr;
};
#endif
diff --git a/examples/opengl/qopenglwidget/glwidget.cpp b/examples/opengl/qopenglwidget/glwidget.cpp
index 5057291f12..89c8469662 100644
--- a/examples/opengl/qopenglwidget/glwidget.cpp
+++ b/examples/opengl/qopenglwidget/glwidget.cpp
@@ -68,14 +68,6 @@ const int bubbleNum = 8;
GLWidget::GLWidget(MainWindow *mw, bool button, const QColor &background)
: m_mainWindow(mw),
- m_showBubbles(true),
- m_qtLogo(true),
- m_frames(0),
- m_program1(0),
- m_program2(0),
- m_texture(0),
- m_transparent(false),
- m_btn(0),
m_hasButton(button),
m_background(background)
{
diff --git a/examples/opengl/qopenglwidget/glwidget.h b/examples/opengl/qopenglwidget/glwidget.h
index 0ad2581cb8..99288261c0 100644
--- a/examples/opengl/qopenglwidget/glwidget.h
+++ b/examples/opengl/qopenglwidget/glwidget.h
@@ -98,34 +98,34 @@ private:
void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
MainWindow *m_mainWindow;
- qreal m_fAngle;
- qreal m_fScale;
- bool m_showBubbles;
+ qreal m_fAngle = 0;
+ qreal m_fScale = 1;
+ bool m_showBubbles = true;
QVector<QVector3D> m_vertices;
QVector<QVector3D> m_normals;
- bool m_qtLogo;
- QList<Bubble *> m_bubbles;
- int m_frames;
+ bool m_qtLogo = true;
+ QVector<Bubble *> m_bubbles;
+ int m_frames = 0;
QElapsedTimer m_time;
- QOpenGLShader *m_vshader1;
- QOpenGLShader *m_fshader1;
- QOpenGLShader *m_vshader2;
- QOpenGLShader *m_fshader2;
- QOpenGLShaderProgram *m_program1;
- QOpenGLShaderProgram *m_program2;
- QOpenGLTexture *m_texture;
+ QOpenGLShader *m_vshader1 = nullptr;
+ QOpenGLShader *m_fshader1 = nullptr;
+ QOpenGLShader *m_vshader2 = nullptr;
+ QOpenGLShader *m_fshader2 = nullptr;
+ QOpenGLShaderProgram *m_program1 = nullptr;
+ QOpenGLShaderProgram *m_program2 = nullptr;
+ QOpenGLTexture *m_texture = nullptr;
QOpenGLBuffer m_vbo1;
QOpenGLBuffer m_vbo2;
- int m_vertexAttr1;
- int m_normalAttr1;
- int m_matrixUniform1;
- int m_vertexAttr2;
- int m_normalAttr2;
- int m_texCoordAttr2;
- int m_matrixUniform2;
- int m_textureUniform2;
- bool m_transparent;
- QPushButton *m_btn;
+ int m_vertexAttr1 = 0;
+ int m_normalAttr1 = 0;
+ int m_matrixUniform1 = 0;
+ int m_vertexAttr2 = 0;
+ int m_normalAttr2 = 0;
+ int m_texCoordAttr2 = 0;
+ int m_matrixUniform2 = 0;
+ int m_textureUniform2 = 0;
+ bool m_transparent = false;
+ QPushButton *m_btn = nullptr;
bool m_hasButton;
QColor m_background;
};
diff --git a/examples/opengl/qopenglwindow/main.cpp b/examples/opengl/qopenglwindow/main.cpp
index 8932269ddf..7ce4dd0977 100644
--- a/examples/opengl/qopenglwindow/main.cpp
+++ b/examples/opengl/qopenglwindow/main.cpp
@@ -51,6 +51,7 @@
#include <QOpenGLWindow>
#include <QScreen>
#include <QPainter>
+#include <QPainterPath>
#include <QGuiApplication>
#include <QMatrix4x4>
#include <QStaticText>
diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp
index 1644233614..307190f308 100644
--- a/examples/opengl/textures/glwidget.cpp
+++ b/examples/opengl/textures/glwidget.cpp
@@ -53,17 +53,6 @@
#include <QOpenGLTexture>
#include <QMouseEvent>
-GLWidget::GLWidget(QWidget *parent)
- : QOpenGLWidget(parent),
- clearColor(Qt::black),
- xRot(0),
- yRot(0),
- zRot(0),
- program(0)
-{
- memset(textures, 0, sizeof(textures));
-}
-
GLWidget::~GLWidget()
{
makeCurrent();
diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h
index 0db2695c6a..585d44dbfe 100644
--- a/examples/opengl/textures/glwidget.h
+++ b/examples/opengl/textures/glwidget.h
@@ -63,7 +63,7 @@ class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
Q_OBJECT
public:
- explicit GLWidget(QWidget *parent = 0);
+ using QOpenGLWidget::QOpenGLWidget;
~GLWidget();
QSize minimumSizeHint() const override;
@@ -85,13 +85,13 @@ protected:
private:
void makeObject();
- QColor clearColor;
+ QColor clearColor = Qt::black;
QPoint lastPos;
- int xRot;
- int yRot;
- int zRot;
- QOpenGLTexture *textures[6];
- QOpenGLShaderProgram *program;
+ int xRot = 0;
+ int yRot = 0;
+ int zRot = 0;
+ QOpenGLTexture *textures[6] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
+ QOpenGLShaderProgram *program = nullptr;
QOpenGLBuffer vbo;
};
diff --git a/examples/opengl/threadedqopenglwidget/glwidget.cpp b/examples/opengl/threadedqopenglwidget/glwidget.cpp
index cc528a734a..2101575fd4 100644
--- a/examples/opengl/threadedqopenglwidget/glwidget.cpp
+++ b/examples/opengl/threadedqopenglwidget/glwidget.cpp
@@ -115,12 +115,7 @@ void GLWidget::grabContext()
m_renderer->unlockRenderer();
}
-Renderer::Renderer(GLWidget *w)
- : m_inited(false),
- m_glwidget(w),
- m_exiting(false)
-{
-}
+Renderer::Renderer(GLWidget *w) : m_glwidget(w) {}
void Renderer::paintQtLogo()
{
diff --git a/examples/opengl/threadedqopenglwidget/glwidget.h b/examples/opengl/threadedqopenglwidget/glwidget.h
index c33f7e51a7..8dc84dd0b1 100644
--- a/examples/opengl/threadedqopenglwidget/glwidget.h
+++ b/examples/opengl/threadedqopenglwidget/glwidget.h
@@ -88,29 +88,29 @@ private:
void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
- bool m_inited;
- qreal m_fAngle;
- qreal m_fScale;
+ bool m_inited = false;
+ qreal m_fAngle = 0;
+ qreal m_fScale = 1;
QVector<QVector3D> vertices;
QVector<QVector3D> normals;
QOpenGLShaderProgram program;
QOpenGLBuffer vbo;
- int vertexAttr;
- int normalAttr;
- int matrixUniform;
- GLWidget *m_glwidget;
+ int vertexAttr = 0;
+ int normalAttr = 0;
+ int matrixUniform = 0;
+ GLWidget *m_glwidget = nullptr;
QMutex m_renderMutex;
QElapsedTimer m_elapsed;
QMutex m_grabMutex;
QWaitCondition m_grabCond;
- bool m_exiting;
+ bool m_exiting = false;
};
class GLWidget : public QOpenGLWidget
{
Q_OBJECT
public:
- explicit GLWidget(QWidget *parent = 0);
+ explicit GLWidget(QWidget *parent = nullptr);
~GLWidget();
protected:
diff --git a/examples/qpa/qrasterwindow/main.cpp b/examples/qpa/qrasterwindow/main.cpp
index 958da2205a..699c950c27 100644
--- a/examples/qpa/qrasterwindow/main.cpp
+++ b/examples/qpa/qrasterwindow/main.cpp
@@ -50,6 +50,7 @@
#include <QRasterWindow>
#include <QPainter>
+#include <QPainterPath>
#include <QGuiApplication>
#include <QMatrix4x4>
#include <QTimer>
diff --git a/examples/sql/doc/src/drilldown.qdoc b/examples/sql/doc/src/drilldown.qdoc
index 7a8aa2037a..a7a9601c26 100644
--- a/examples/sql/doc/src/drilldown.qdoc
+++ b/examples/sql/doc/src/drilldown.qdoc
@@ -425,7 +425,7 @@
The \c findWindow() function simply searches through the list of
existing windows, returning a pointer to the window that matches
- the given item ID, or 0 if the window doesn't exists.
+ the given item ID, or \nullptr if the window doesn't exists.
Finally, let's take a quick look at our custom \c ImageItem class:
@@ -437,6 +437,9 @@
\snippet drilldown/imageitem.h 0
+ We declare a \c Type enum value for our custom item and reimplement
+ \l{QGreaphicsItem::}{type()}. This is done so we can safely use
+ qgraphicsitem_cast().
In addition, we implement a public \c id() function to be able to
identify the associated location and a public \c adjust() function
that can be called to ensure that the image item is given the
diff --git a/examples/sql/drilldown/imageitem.h b/examples/sql/drilldown/imageitem.h
index abb9103c7e..324c847b12 100644
--- a/examples/sql/drilldown/imageitem.h
+++ b/examples/sql/drilldown/imageitem.h
@@ -60,8 +60,11 @@ class ImageItem : public QObject, public QGraphicsPixmapItem
Q_OBJECT
public:
+ enum { Type = UserType + 1 };
+
ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent = nullptr);
+ int type() const override { return Type; }
void adjust();
int id() const;
diff --git a/examples/sql/masterdetail/dialog.cpp b/examples/sql/masterdetail/dialog.cpp
index bb1812eace..3267352b07 100644
--- a/examples/sql/masterdetail/dialog.cpp
+++ b/examples/sql/masterdetail/dialog.cpp
@@ -86,7 +86,7 @@ void Dialog::submit()
int albumId = addNewAlbum(title, artistId);
QStringList tracks;
- tracks = tracksEditor->text().split(',', QString::SkipEmptyParts);
+ tracks = tracksEditor->text().split(QLatin1Char(','), Qt::SkipEmptyParts);
addTracks(albumId, tracks);
increaseAlbumCount(indexOfArtist(artist));
diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp
index 7f3479619a..2ff9a10d91 100644
--- a/examples/sql/masterdetail/mainwindow.cpp
+++ b/examples/sql/masterdetail/mainwindow.cpp
@@ -320,7 +320,7 @@ QGroupBox* MainWindow::createAlbumGroupBox()
this, &MainWindow::showAlbumDetails);
QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(albumView, 0, 0);
+ layout->addWidget(albumView, 0, { });
box->setLayout(layout);
return box;
diff --git a/examples/widgets/animation/easing/window.cpp b/examples/widgets/animation/easing/window.cpp
index d1d6348361..378af07535 100644
--- a/examples/widgets/animation/easing/window.cpp
+++ b/examples/widgets/animation/easing/window.cpp
@@ -67,7 +67,7 @@ Window::Window(QWidget *parent)
connect(m_ui.easingCurvePicker, &QListWidget::currentRowChanged,
this, &Window::curveChanged);
- connect(m_ui.buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
+ connect(m_ui.buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
this, &Window::pathChanged);
connect(m_ui.periodSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &Window::periodChanged);
@@ -180,9 +180,10 @@ void Window::curveChanged(int row)
m_ui.overshootSpinBox->setEnabled(curveType >= QEasingCurve::InBack && curveType <= QEasingCurve::OutInBack);
}
-void Window::pathChanged(int index)
+void Window::pathChanged(QAbstractButton *button)
{
- m_anim->setPathType((Animation::PathType)index);
+ const int index = m_ui.buttonGroup->id(button);
+ m_anim->setPathType(Animation::PathType(index));
}
void Window::periodChanged(double value)
diff --git a/examples/widgets/animation/easing/window.h b/examples/widgets/animation/easing/window.h
index 541377a981..0c49dd6e8a 100644
--- a/examples/widgets/animation/easing/window.h
+++ b/examples/widgets/animation/easing/window.h
@@ -69,7 +69,7 @@ public:
Window(QWidget *parent = nullptr);
private slots:
void curveChanged(int row);
- void pathChanged(int index);
+ void pathChanged(QAbstractButton *button);
void periodChanged(double);
void amplitudeChanged(double);
void overshootChanged(double);
diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp
index ce5597bbdd..d0a849e0b8 100644
--- a/examples/widgets/desktop/screenshot/screenshot.cpp
+++ b/examples/widgets/desktop/screenshot/screenshot.cpp
@@ -109,7 +109,7 @@ void Screenshot::resizeEvent(QResizeEvent * /* event */)
{
QSize scaledSize = originalPixmap.size();
scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio);
- if (!screenshotLabel->pixmap() || scaledSize != screenshotLabel->pixmap()->size())
+ if (scaledSize != screenshotLabel->pixmap(Qt::ReturnByValue).size())
updateScreenshotLabel();
}
//! [1]
diff --git a/examples/widgets/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp
index e30166beac..9cfe651669 100644
--- a/examples/widgets/desktop/systray/window.cpp
+++ b/examples/widgets/desktop/systray/window.cpp
@@ -111,7 +111,7 @@ void Window::setVisible(bool visible)
//! [2]
void Window::closeEvent(QCloseEvent *event)
{
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MACOS
if (!event->spontaneous() || !isVisible()) {
return;
}
diff --git a/examples/widgets/dialogs/standarddialogs/dialog.cpp b/examples/widgets/dialogs/standarddialogs/dialog.cpp
index df77d03567..cd7e8085a2 100644
--- a/examples/widgets/dialogs/standarddialogs/dialog.cpp
+++ b/examples/widgets/dialogs/standarddialogs/dialog.cpp
@@ -329,7 +329,8 @@ void Dialog::setDouble()
//! [1]
bool ok;
double d = QInputDialog::getDouble(this, tr("QInputDialog::getDouble()"),
- tr("Amount:"), 37.56, -10000, 10000, 2, &ok);
+ tr("Amount:"), 37.56, -10000, 10000, 2, &ok,
+ Qt::WindowFlags(), 1);
if (ok)
doubleLabel->setText(QString("$%1").arg(d));
//! [1]
@@ -492,7 +493,7 @@ void Dialog::questionMessage()
void Dialog::warningMessage()
{
QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"),
- MESSAGE, nullptr, this);
+ MESSAGE, { }, this);
msgBox.setDetailedText(MESSAGE_DETAILS);
msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole);
msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole);
diff --git a/examples/widgets/doc/dropsite.qdoc b/examples/widgets/doc/dropsite.qdoc
index af8766a308..d8d09612f6 100644
--- a/examples/widgets/doc/dropsite.qdoc
+++ b/examples/widgets/doc/dropsite.qdoc
@@ -176,16 +176,16 @@
\snippet draganddrop/dropsite/dropsitewindow.cpp constructor part3
- Two QPushButton objects, \c clearButton and \c quitButton, are instantiated
- and added to \c buttonBox - a QDialogButtonBox object. We use
- QDialogButtonBox here to ensure that the push buttons are presented in a
+ Three QPushButton objects, \c clearButton, \c copyButton, and \c quitButton,
+ are instantiated and added to \c buttonBox - a QDialogButtonBox object. We
+ use QDialogButtonBox here to ensure that the push buttons are presented in a
layout that conforms to the platform's style.
\snippet draganddrop/dropsite/dropsitewindow.cpp constructor part4
- The \l{QPushButton::clicked()}{clicked()} signals for \c quitButton and
- \c clearButton are connected to \l{QWidget::close()}{close()} and
- \c clear(), respectively.
+ The \l{QPushButton::clicked()}{clicked()} signals for \c copyButton,
+ \c clearButton, and \c quitButton are connected to \c copy(),
+ \c clear() and \l{QWidget::close()}{close()}, respectively.
For the layout, we use a QVBoxLayout, \c mainLayout, to arrange our widgets
vertically. We also set the window title to "Drop Site" and the minimum
diff --git a/examples/xml/saxbookmarks/doc/src/saxbookmarks.qdoc b/examples/widgets/doc/src/gallery.qdoc
index 0cd89e641e..455099ddce 100644
--- a/examples/xml/saxbookmarks/doc/src/saxbookmarks.qdoc
+++ b/examples/widgets/doc/src/gallery.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -26,16 +26,11 @@
****************************************************************************/
/*!
- \example saxbookmarks
- \title SAX Bookmarks Example
- \brief Demonstrates how to read XBEL files.
- \ingroup xml-examples
+ \example gallery
+ \title Widgets Gallery Example
+ \ingroup examples-widgets
+ \brief The Widgets Gallery example shows widgets relevant for designing UIs.
- This example uses Qt's SAX API to read and parse the files. The DOM Bookmarks
- example provides an alternative way to read this type of file.
-
- \image saxbookmarks-example.png
-
- See the \l{XML Bookmark Exchange Language Resource Page} for more
- information about XBEL files.
+ This example demonstrates widgets typically used in dialogs and forms.
+ It also allows for changing the style.
*/
diff --git a/examples/widgets/doc/src/icons.qdoc b/examples/widgets/doc/src/icons.qdoc
index 7aae0491d6..24be09a7a9 100644
--- a/examples/widgets/doc/src/icons.qdoc
+++ b/examples/widgets/doc/src/icons.qdoc
@@ -232,8 +232,8 @@
combinations of states and modes for a given icon.
\li \c IconSizeSpinBox is a subclass of QSpinBox that lets the
user enter icon sizes (e.g., "48 x 48").
- \li \c ImageDelegate is a subclass of QItemDelegate that provides
- comboboxes for letting the user set the mode and state
+ \li \c ImageDelegate is a subclass of QStyledItemDelegate that
+ provides comboboxes for letting the user set the mode and state
associated with an image.
\endlist
@@ -468,7 +468,6 @@
loaded into the application.
\snippet widgets/icons/mainwindow.cpp 13
- \snippet widgets/icons/mainwindow.cpp 14
We retrieve the image name using the QFileInfo::baseName()
function that returns the base name of the file without the path,
@@ -486,8 +485,6 @@
Qt::ItemIsEditable flag. Table items are editable by default.
\snippet widgets/icons/mainwindow.cpp 15
- \snippet widgets/icons/mainwindow.cpp 16
- \snippet widgets/icons/mainwindow.cpp 17
Then we create the second and third items in the row making the
default mode Normal and the default state Off. But if the \uicontrol
@@ -498,7 +495,6 @@
example's \c images subdirectory respect this naming convention.
\snippet widgets/icons/mainwindow.cpp 18
- \snippet widgets/icons/mainwindow.cpp 19
In the end we add the items to the associated row, and use the
QTableWidget::openPersistentEditor() function to create
@@ -522,8 +518,6 @@
application.
\snippet widgets/icons/mainwindow.cpp 8
- \snippet widgets/icons/mainwindow.cpp 9
- \snippet widgets/icons/mainwindow.cpp 10
We also extract the image file's name using the
QTableWidgetItem::data() function. This function takes a
@@ -571,24 +565,22 @@
delegate for the table widget. We create a \c ImageDelegate that
we make the item delegate for our view.
- The QItemDelegate class can be used to provide an editor for an item view
+ The QStyledItemDelegate class can be used to provide an editor for an item view
class that is subclassed from QAbstractItemView. Using a delegate
for this purpose allows the editing mechanism to be customized and
developed independently from the model and view.
- In this example we derive \c ImageDelegate from QItemDelegate.
- QItemDelegate usually provides line editors, while our subclass
+ In this example we derive \c ImageDelegate from QStyledItemDelegate.
+ QStyledItemDelegate usually provides line editors, while our subclass
\c ImageDelegate, provides comboboxes for the mode and state
fields.
\snippet widgets/icons/mainwindow.cpp 22
- \snippet widgets/icons/mainwindow.cpp 23
Then we customize the QTableWidget's horizontal header, and hide
the vertical header.
\snippet widgets/icons/mainwindow.cpp 24
- \snippet widgets/icons/mainwindow.cpp 25
At the end, we connect the QTableWidget::itemChanged() signal to
the \c changeIcon() slot to ensure that the preview area is in
@@ -750,23 +742,23 @@
\snippet widgets/icons/imagedelegate.h 0
- The \c ImageDelegate class is a subclass of QItemDelegate. The
- QItemDelegate class provides display and editing facilities for
- data items from a model. A single QItemDelegate object is
+ The \c ImageDelegate class is a subclass of QStyledItemDelegate. The
+ QStyledItemDelegate class provides display and editing facilities for
+ data items from a model. A single QStyledItemDelegate object is
responsible for all items displayed in a item view (in our case,
a QTableWidget).
- A QItemDelegate can be used to provide an editor for an item view
+ A QStyledItemDelegate can be used to provide an editor for an item view
class that is subclassed from QAbstractItemView. Using a delegate
for this purpose allows the editing mechanism to be customized and
developed independently from the model and view.
\snippet widgets/icons/imagedelegate.h 1
- The default implementation of QItemDelegate creates a QLineEdit.
+ The default implementation of QStyledItemDelegate creates a QLineEdit.
Since we want the editor to be a QComboBox, we need to subclass
- QItemDelegate and reimplement the QItemDelegate::createEditor(),
- QItemDelegate::setEditorData() and QItemDelegate::setModelData()
+ QStyledItemDelegate and reimplement the QStyledItemDelegate::createEditor(),
+ QStyledItemDelegate::setEditorData() and QStyledItemDelegate::setModelData()
functions.
\snippet widgets/icons/imagedelegate.h 2
@@ -783,7 +775,7 @@
\snippet widgets/icons/imagedelegate.cpp 1
- The default QItemDelegate::createEditor() implementation returns
+ The default QStyledItemDelegate::createEditor() implementation returns
the widget used to edit the item specified by the model and item
index for editing. The parent widget and style option are used to
control the appearance of the editor widget.
@@ -803,7 +795,7 @@
\snippet widgets/icons/imagedelegate.cpp 2
- The QItemDelegate::setEditorData() function is used by
+ The QStyledItemDelegate::setEditorData() function is used by
QTableWidget to transfer data from a QTableWidgetItem to the
editor. The data is stored as a string; we use
QComboBox::findText() to locate it in the combobox.
@@ -816,7 +808,7 @@
\snippet widgets/icons/imagedelegate.cpp 3
- The QItemDelegate::setEditorData() function is used by QTableWidget
+ The QStyledItemDelegate::setEditorData() function is used by QTableWidget
to transfer data back from the editor to the \l{QTableWidgetItem}.
\snippet widgets/icons/imagedelegate.cpp 4
diff --git a/examples/widgets/doc/src/imageviewer.qdoc b/examples/widgets/doc/src/imageviewer.qdoc
index 91b6385356..8cf8c2489e 100644
--- a/examples/widgets/doc/src/imageviewer.qdoc
+++ b/examples/widgets/doc/src/imageviewer.qdoc
@@ -175,8 +175,8 @@
will expand to
\code
- if (!imageLabel->pixmap())
- qFatal("ASSERT: "imageLabel->pixmap()" in file ...");
+ if (imageLabel->pixmap(Qt::ReturnByValue).isNull())
+ qFatal("ASSERT: "imageLabel->pixmap(Qt::ReturnByValue).isNull()" in file ...");
\endcode
In release mode, the macro simply disappear. The mode can be set
diff --git a/examples/widgets/doc/src/padnavigator.qdoc b/examples/widgets/doc/src/padnavigator.qdoc
index d8e83978cf..31440b650f 100644
--- a/examples/widgets/doc/src/padnavigator.qdoc
+++ b/examples/widgets/doc/src/padnavigator.qdoc
@@ -545,7 +545,7 @@
with OpenGL, but without OpenGL it avoids unnecessary re-scaling of the
background pixmap.
\li It sets render hints that increase rendering quality.
- \li If OpenGL is supported, a QGLWidget viewport is assigned to the view.
+ \li If OpenGL is supported, a QOpenGLWidget viewport is assigned to the view.
\endlist
Finally, we start the state engine.
diff --git a/examples/widgets/doc/src/styles.qdoc b/examples/widgets/doc/src/styles.qdoc
index 7a7ae20e91..014541a330 100644
--- a/examples/widgets/doc/src/styles.qdoc
+++ b/examples/widgets/doc/src/styles.qdoc
@@ -27,7 +27,6 @@
/*!
\example widgets/styles
- \meta {tag} {gallery}
\title Styles Example
\ingroup examples-widgets
\brief The Styles example illustrates how to create custom widget
diff --git a/examples/widgets/draganddrop/draggableicons/dragwidget.cpp b/examples/widgets/draganddrop/draggableicons/dragwidget.cpp
index 2019645c1d..00671dcf7e 100644
--- a/examples/widgets/draganddrop/draggableicons/dragwidget.cpp
+++ b/examples/widgets/draganddrop/draggableicons/dragwidget.cpp
@@ -142,7 +142,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
if (!child)
return;
- QPixmap pixmap = *child->pixmap();
+ QPixmap pixmap = child->pixmap(Qt::ReturnByValue);
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
diff --git a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
index 2135ba2ef9..4a430ebf56 100644
--- a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
+++ b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
@@ -113,7 +113,7 @@ void DragWidget::dropEvent(QDropEvent *event)
if (event->mimeData()->hasText()) {
const QMimeData *mime = event->mimeData();
QStringList pieces = mime->text().split(QRegularExpression(QStringLiteral("\\s+")),
- QString::SkipEmptyParts);
+ Qt::SkipEmptyParts);
QPoint position = event->pos();
QPoint hotSpot;
diff --git a/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp b/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp
index 2dae83bb22..a937e24a4c 100644
--- a/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp
+++ b/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp
@@ -82,14 +82,21 @@ DropSiteWindow::DropSiteWindow()
//! [constructor part4]
clearButton = new QPushButton(tr("Clear"));
+ copyButton = new QPushButton(tr("Copy"));
quitButton = new QPushButton(tr("Quit"));
buttonBox = new QDialogButtonBox;
buttonBox->addButton(clearButton, QDialogButtonBox::ActionRole);
+ buttonBox->addButton(copyButton, QDialogButtonBox::ActionRole);
+#if !QT_CONFIG(clipboard)
+ copyButton->setVisible(false);
+#endif
+
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
connect(quitButton, &QAbstractButton::clicked, this, &QWidget::close);
connect(clearButton, &QAbstractButton::clicked, dropArea, &DropArea::clear);
+ connect(copyButton, &QAbstractButton::clicked, this, &DropSiteWindow::copy);
//! [constructor part4]
//! [constructor part5]
@@ -108,6 +115,7 @@ DropSiteWindow::DropSiteWindow()
void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
{
formatsTable->setRowCount(0);
+ copyButton->setEnabled(false);
if (!mimeData)
return;
//! [updateFormatsTable() part1]
@@ -145,5 +153,18 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
}
formatsTable->resizeColumnToContents(0);
+#if QT_CONFIG(clipboard)
+ copyButton->setEnabled(formatsTable->rowCount() > 0);
+#endif
}
//! [updateFormatsTable() part4]
+
+void DropSiteWindow::copy()
+{
+#if QT_CONFIG(clipboard)
+ QString text;
+ for (int row = 0, rowCount = formatsTable->rowCount(); row < rowCount; ++row)
+ text += formatsTable->item(row, 0)->text() + ": " + formatsTable->item(row, 1)->text() + '\n';
+ QGuiApplication::clipboard()->setText(text);
+#endif
+}
diff --git a/examples/widgets/draganddrop/dropsite/dropsitewindow.h b/examples/widgets/draganddrop/dropsite/dropsitewindow.h
index d80476f369..a40b481637 100644
--- a/examples/widgets/draganddrop/dropsite/dropsitewindow.h
+++ b/examples/widgets/draganddrop/dropsite/dropsitewindow.h
@@ -72,6 +72,7 @@ public:
public slots:
void updateFormatsTable(const QMimeData *mimeData);
+ void copy();
private:
DropArea *dropArea;
@@ -79,6 +80,7 @@ private:
QTableWidget *formatsTable;
QPushButton *clearButton;
+ QPushButton *copyButton;
QPushButton *quitButton;
QDialogButtonBox *buttonBox;
};
diff --git a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp b/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp
index 451b53f623..a02b1cb42a 100644
--- a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp
+++ b/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp
@@ -163,8 +163,8 @@ void DragWidget::dropEvent(QDropEvent *event)
}
//! [11] //! [12]
} else if (event->mimeData()->hasText()) {
- QStringList pieces = event->mimeData()->text().split(QRegularExpression(QStringLiteral("\\s+")),
- QString::SkipEmptyParts);
+ QStringList pieces = event->mimeData()->text().split(
+ QRegularExpression(QStringLiteral("\\s+")), Qt::SkipEmptyParts);
QPoint position = event->pos();
for (const QString &piece : pieces) {
@@ -208,7 +208,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
//! [16]
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
- drag->setPixmap(*child->pixmap());
+ drag->setPixmap(child->pixmap(Qt::ReturnByValue));
drag->setHotSpot(hotSpot);
child->hide();
diff --git a/examples/widgets/gallery/gallery.pro b/examples/widgets/gallery/gallery.pro
new file mode 100644
index 0000000000..38bf8d6d8e
--- /dev/null
+++ b/examples/widgets/gallery/gallery.pro
@@ -0,0 +1,10 @@
+QT += widgets
+requires(qtConfig(combobox))
+
+HEADERS = widgetgallery.h
+SOURCES = main.cpp \
+ widgetgallery.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/widgets/gallery
+INSTALLS += target
diff --git a/examples/xml/saxbookmarks/main.cpp b/examples/widgets/gallery/main.cpp
index 8e577ca700..7f1782c84e 100644
--- a/examples/xml/saxbookmarks/main.cpp
+++ b/examples/widgets/gallery/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -50,13 +50,26 @@
#include <QApplication>
-#include "mainwindow.h"
+#include "widgetgallery.h"
int main(int argc, char *argv[])
{
+ bool useHighDpiScaling = true;
+
+ for (int i = 1; i < argc; ++i) {
+ if (qstrcmp(argv[i], "--no-scaling") == 0)
+ useHighDpiScaling = false;
+ }
+
+ if (useHighDpiScaling) {
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ } else {
+ QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
+ }
+
QApplication app(argc, argv);
- MainWindow mainWin;
- mainWin.show();
- mainWin.open();
- return app.exec();
+ WidgetGallery gallery;
+ gallery.show();
+ return QCoreApplication::exec();
}
diff --git a/examples/widgets/gallery/widgetgallery.cpp b/examples/widgets/gallery/widgetgallery.cpp
new file mode 100644
index 0000000000..3bbe8943d1
--- /dev/null
+++ b/examples/widgets/gallery/widgetgallery.cpp
@@ -0,0 +1,474 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples 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 "widgetgallery.h"
+
+#include <QApplication>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QCommandLinkButton>
+#include <QDateTimeEdit>
+#include <QDial>
+#include <QDialogButtonBox>
+#include <QFileSystemModel>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QMenu>
+#include <QLabel>
+#include <QLineEdit>
+#include <QListWidget>
+#include <QPlainTextEdit>
+#include <QProgressBar>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QScrollBar>
+#include <QShortcut>
+#include <QSpinBox>
+#include <QStandardItemModel>
+#include <QStyle>
+#include <QStyleFactory>
+#include <QTextBrowser>
+#include <QTreeView>
+#include <QTableWidget>
+#include <QTextEdit>
+#include <QToolBox>
+#include <QToolButton>
+
+#include <QIcon>
+#include <QDesktopServices>
+#include <QScreen>
+#include <QWindow>
+
+#include <QDebug>
+#include <QLibraryInfo>
+#include <QSysInfo>
+#include <QTextStream>
+#include <QTimer>
+
+static inline QString className(const QObject *o)
+{
+ return QString::fromUtf8(o->metaObject()->className());
+}
+
+static inline void setClassNameToolTip(QWidget *w)
+{
+ w->setToolTip(className(w));
+}
+
+static QString helpUrl(const QString &page)
+{
+ QString result;
+ QTextStream(&result) << "https://doc.qt.io/qt-" << QT_VERSION_MAJOR
+ << '/' << page << ".html";
+ return result;
+}
+
+static inline QString helpUrl(const QWidget *w)
+{
+ return helpUrl(className(w).toLower());
+}
+
+static void launchHelp(const QWidget *w)
+{
+ QDesktopServices::openUrl(helpUrl(w));
+}
+
+static void launchModuleHelp()
+{
+ QDesktopServices::openUrl(helpUrl(QLatin1String("qtwidgets-index")));
+}
+
+template <class Widget>
+Widget *createWidget(const char *name, QWidget *parent = nullptr)
+{
+ auto result = new Widget(parent);
+ result->setObjectName(QLatin1String(name));
+ setClassNameToolTip(result);
+ return result;
+}
+
+template <class Widget, class Parameter>
+Widget *createWidget1(const Parameter &p1, const char *name, QWidget *parent = nullptr)
+{
+ auto result = new Widget(p1, parent);
+ result->setObjectName(QLatin1String(name));
+ setClassNameToolTip(result);
+ return result;
+}
+
+QTextStream &operator<<(QTextStream &str, const QRect &r)
+{
+ str << r.width() << 'x' << r.height() << Qt::forcesign << r.x() << r.y()
+ << Qt::noforcesign;
+ return str;
+}
+
+static QString highDpiScaleFactorRoundingPolicy()
+{
+ QString result;
+ QDebug(&result) << QGuiApplication::highDpiScaleFactorRoundingPolicy();
+ if (result.endsWith(QLatin1Char(')')))
+ result.chop(1);
+ const int lastSep = result.lastIndexOf(QLatin1String("::"));
+ if (lastSep != -1)
+ result.remove(0, lastSep + 2);
+ return result;
+}
+
+WidgetGallery::WidgetGallery(QWidget *parent)
+ : QDialog(parent)
+ , progressBar(createProgressBar())
+{
+ setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
+
+ auto styleComboBox = createWidget<QComboBox>("styleComboBox");
+ const QString defaultStyleName = QApplication::style()->objectName();
+ QStringList styleNames = QStyleFactory::keys();
+ for (int i = 1, size = styleNames.size(); i < size; ++i) {
+ if (defaultStyleName.compare(styleNames.at(i), Qt::CaseInsensitive) == 0) {
+ styleNames.swapItemsAt(0, i);
+ break;
+ }
+ }
+ styleComboBox->addItems(styleNames);
+
+ auto styleLabel = createWidget1<QLabel>(tr("&Style:"), "styleLabel");
+ styleLabel->setBuddy(styleComboBox);
+
+ auto helpLabel = createWidget1<QLabel>(tr("Press F1 over a widget to see Documentation"), "helpLabel");
+
+ auto disableWidgetsCheckBox = createWidget1<QCheckBox>(tr("&Disable widgets"), "disableWidgetsCheckBox");
+
+ auto buttonsGroupBox = createButtonsGroupBox();
+ auto itemViewTabWidget = createItemViewTabWidget();
+ auto simpleInputWidgetsGroupBox = createSimpleInputWidgetsGroupBox();
+ auto textToolBox = createTextToolBox();
+
+ connect(styleComboBox, &QComboBox::textActivated,
+ this, &WidgetGallery::changeStyle);
+ connect(disableWidgetsCheckBox, &QCheckBox::toggled,
+ buttonsGroupBox, &QWidget::setDisabled);
+ connect(disableWidgetsCheckBox, &QCheckBox::toggled,
+ textToolBox, &QWidget::setDisabled);
+ connect(disableWidgetsCheckBox, &QCheckBox::toggled,
+ itemViewTabWidget, &QWidget::setDisabled);
+ connect(disableWidgetsCheckBox, &QCheckBox::toggled,
+ simpleInputWidgetsGroupBox, &QWidget::setDisabled);
+
+ auto topLayout = new QHBoxLayout;
+ topLayout->addWidget(styleLabel);
+ topLayout->addWidget(styleComboBox);
+ topLayout->addStretch(1);
+ topLayout->addWidget(helpLabel);
+ topLayout->addStretch(1);
+ topLayout->addWidget(disableWidgetsCheckBox);
+
+ auto dialogButtonBox = createWidget1<QDialogButtonBox>(QDialogButtonBox::Help | QDialogButtonBox::Close,
+ "dialogButtonBox");
+ connect(dialogButtonBox, &QDialogButtonBox::helpRequested, this, launchModuleHelp);
+ connect(dialogButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
+
+ auto mainLayout = new QGridLayout(this);
+ mainLayout->addLayout(topLayout, 0, 0, 1, 2);
+ mainLayout->addWidget(buttonsGroupBox, 1, 0);
+ mainLayout->addWidget(simpleInputWidgetsGroupBox, 1, 1);
+ mainLayout->addWidget(itemViewTabWidget, 2, 0);
+ mainLayout->addWidget(textToolBox, 2, 1);
+ mainLayout->addWidget(progressBar, 3, 0, 1, 2);
+ mainLayout->addWidget(dialogButtonBox, 4, 0, 1, 2);
+
+ setWindowTitle(tr("Widget Gallery Qt %1").arg(QT_VERSION_STR));
+
+ new QShortcut(QKeySequence::HelpContents, this, this, &WidgetGallery::helpOnCurrentWidget);
+}
+
+void WidgetGallery::setVisible(bool visible)
+{
+ QDialog::setVisible(visible);
+ if (visible) {
+ connect(windowHandle(), &QWindow::screenChanged, this, &WidgetGallery::updateSystemInfo);
+ updateSystemInfo();
+ }
+}
+
+void WidgetGallery::changeStyle(const QString &styleName)
+{
+ QApplication::setStyle(QStyleFactory::create(styleName));
+}
+
+void WidgetGallery::advanceProgressBar()
+{
+ int curVal = progressBar->value();
+ int maxVal = progressBar->maximum();
+ progressBar->setValue(curVal + (maxVal - curVal) / 100);
+}
+
+QGroupBox *WidgetGallery::createButtonsGroupBox()
+{
+ auto result = createWidget1<QGroupBox>(tr("Buttons"), "buttonsGroupBox");
+
+ auto defaultPushButton = createWidget1<QPushButton>(tr("Default Push Button"), "defaultPushButton");
+ defaultPushButton->setDefault(true);
+
+ auto togglePushButton = createWidget1<QPushButton>(tr("Toggle Push Button"), "togglePushButton");
+ togglePushButton->setCheckable(true);
+ togglePushButton->setChecked(true);
+
+ auto flatPushButton = createWidget1<QPushButton>(tr("Flat Push Button"), "flatPushButton");
+ flatPushButton->setFlat(true);
+
+ auto toolButton = createWidget<QToolButton>("toolButton");
+ toolButton->setText(tr("Tool Button"));
+
+ auto menuToolButton = createWidget<QToolButton>("menuButton");
+ menuToolButton->setText(tr("Menu Button"));
+ auto toolMenu = new QMenu(menuToolButton);
+ menuToolButton->setPopupMode(QToolButton::InstantPopup);
+ toolMenu->addAction("Option");
+ toolMenu->addSeparator();
+ auto action = toolMenu->addAction("Checkable Option");
+ action->setCheckable(true);
+ menuToolButton->setMenu(toolMenu);
+ auto toolLayout = new QHBoxLayout;
+ toolLayout->addWidget(toolButton);
+ toolLayout->addWidget(menuToolButton);
+
+ auto commandLinkButton = createWidget1<QCommandLinkButton>(tr("Command Link Button"), "commandLinkButton");
+ commandLinkButton->setDescription(tr("Description"));
+
+ auto buttonLayout = new QVBoxLayout;
+ buttonLayout->addWidget(defaultPushButton);
+ buttonLayout->addWidget(togglePushButton);
+ buttonLayout->addWidget(flatPushButton);
+ buttonLayout->addLayout(toolLayout);
+ buttonLayout->addWidget(commandLinkButton);
+ buttonLayout->addStretch(1);
+
+ auto radioButton1 = createWidget1<QRadioButton>(tr("Radio button 1"), "radioButton1");
+ auto radioButton2 = createWidget1<QRadioButton>(tr("Radio button 2"), "radioButton2");
+ auto radioButton3 = createWidget1<QRadioButton>(tr("Radio button 3"), "radioButton3");
+ radioButton1->setChecked(true);
+
+ auto checkBox = createWidget1<QCheckBox>(tr("Tri-state check box"), "checkBox");
+ checkBox->setTristate(true);
+ checkBox->setCheckState(Qt::PartiallyChecked);
+
+ auto checkableLayout = new QVBoxLayout;
+ checkableLayout->addWidget(radioButton1);
+ checkableLayout->addWidget(radioButton2);
+ checkableLayout->addWidget(radioButton3);
+ checkableLayout->addWidget(checkBox);
+ checkableLayout->addStretch(1);
+
+ auto mainLayout = new QHBoxLayout(result);
+ mainLayout->addLayout(buttonLayout);
+ mainLayout->addLayout(checkableLayout);
+ mainLayout->addStretch();
+ return result;
+}
+
+static QWidget *embedIntoHBoxLayout(QWidget *w, int margin = 5)
+{
+ auto result = new QWidget;
+ auto layout = new QHBoxLayout(result);
+ layout->setContentsMargins(margin, margin, margin, margin);
+ layout->addWidget(w);
+ return result;
+}
+
+QToolBox *WidgetGallery::createTextToolBox()
+{
+ auto result = createWidget<QToolBox>("toolBox");
+
+ const QString plainText = tr("Twinkle, twinkle, little star,\n"
+ "How I wonder what you are.\n"
+ "Up above the world so high,\n"
+ "Like a diamond in the sky.\n"
+ "Twinkle, twinkle, little star,\n"
+ "How I wonder what you are!\n");
+ // Create centered/italic HTML rich text
+ QString richText = QLatin1String("<html><head/><body><i>");
+ for (const auto &line : plainText.splitRef(QLatin1Char('\n')))
+ richText += QLatin1String("<center>") + line + QLatin1String("</center>");
+ richText += QLatin1String("</i></body></html>");
+
+ auto textEdit = createWidget1<QTextEdit>(richText, "textEdit");
+ auto plainTextEdit = createWidget1<QPlainTextEdit>(plainText, "plainTextEdit");
+
+ systemInfoTextBrowser = createWidget<QTextBrowser>("systemInfoTextBrowser");
+
+ result->addItem(embedIntoHBoxLayout(textEdit), tr("Text Edit"));
+ result->addItem(embedIntoHBoxLayout(plainTextEdit), tr("Plain Text Edit"));
+ result->addItem(embedIntoHBoxLayout(systemInfoTextBrowser), tr("Text Browser"));
+ return result;
+}
+
+QTabWidget *WidgetGallery::createItemViewTabWidget()
+{
+ auto result = createWidget<QTabWidget>("bottomLeftTabWidget");
+ result->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
+
+ auto treeView = createWidget<QTreeView>("treeView");
+ auto fileSystemModel = new QFileSystemModel(treeView);
+ fileSystemModel->setRootPath(QDir::rootPath());
+ treeView->setModel(fileSystemModel);
+
+ auto tableWidget = createWidget<QTableWidget>("tableWidget");
+ tableWidget->setRowCount(10);
+ tableWidget->setColumnCount(10);
+
+ auto listModel = new QStandardItemModel(0, 1, result);
+ listModel->appendRow(new QStandardItem(QIcon(QLatin1String(":/qt-project.org/styles/commonstyle/images/diropen-128.png")),
+ tr("Directory")));
+ listModel->appendRow(new QStandardItem(QIcon(QLatin1String(":/qt-project.org/styles/commonstyle/images/computer-32.png")),
+ tr("Computer")));
+
+ auto listView = createWidget<QListView>("listView");
+ listView->setModel(listModel);
+
+ auto iconModeListView = createWidget<QListView>("iconModeListView");
+ iconModeListView->setViewMode(QListView::IconMode);
+ iconModeListView->setModel(listModel);
+
+ result->addTab(embedIntoHBoxLayout(treeView), tr("&Tree View"));
+ result->addTab(embedIntoHBoxLayout(tableWidget), tr("T&able"));
+ result->addTab(embedIntoHBoxLayout(listView), tr("&List"));
+ result->addTab(embedIntoHBoxLayout(iconModeListView), tr("&Icon Mode List"));
+ return result;
+}
+
+QGroupBox *WidgetGallery::createSimpleInputWidgetsGroupBox()
+{
+ auto result = createWidget1<QGroupBox>(tr("Simple Input Widgets"), "bottomRightGroupBox");
+ result->setCheckable(true);
+ result->setChecked(true);
+
+ auto lineEdit = createWidget1<QLineEdit>("s3cRe7", "lineEdit");
+ lineEdit->setClearButtonEnabled(true);
+ lineEdit->setEchoMode(QLineEdit::Password);
+
+ auto spinBox = createWidget<QSpinBox>("spinBox", result);
+ spinBox->setValue(50);
+
+ auto dateTimeEdit = createWidget<QDateTimeEdit>("dateTimeEdit", result);
+ dateTimeEdit->setDateTime(QDateTime::currentDateTime());
+
+ auto slider = createWidget<QSlider>("slider", result);
+ slider->setOrientation(Qt::Horizontal);
+ slider->setValue(40);
+
+ auto scrollBar = createWidget<QScrollBar>("scrollBar", result);
+ scrollBar->setOrientation(Qt::Horizontal);
+ setClassNameToolTip(scrollBar);
+ scrollBar->setValue(60);
+
+ auto dial = createWidget<QDial>("dial", result);
+ dial->setValue(30);
+ dial->setNotchesVisible(true);
+
+ auto layout = new QGridLayout(result);
+ layout->addWidget(lineEdit, 0, 0, 1, 2);
+ layout->addWidget(spinBox, 1, 0, 1, 2);
+ layout->addWidget(dateTimeEdit, 2, 0, 1, 2);
+ layout->addWidget(slider, 3, 0);
+ layout->addWidget(scrollBar, 4, 0);
+ layout->addWidget(dial, 3, 1, 2, 1);
+ layout->setRowStretch(5, 1);
+ return result;
+}
+
+QProgressBar *WidgetGallery::createProgressBar()
+{
+ auto result = createWidget<QProgressBar>("progressBar");
+ result->setRange(0, 10000);
+ result->setValue(0);
+
+ auto timer = new QTimer(this);
+ connect(timer, &QTimer::timeout, this, &WidgetGallery::advanceProgressBar);
+ timer->start(1000);
+ return result;
+}
+
+void WidgetGallery::updateSystemInfo()
+{
+ QString systemInfo;
+ QTextStream str(&systemInfo);
+ str << "<html><head/><body><h3>Build</h3><p>" << QLibraryInfo::build() << "</p>"
+ << "<h3>Operating System</h3><p>" << QSysInfo::prettyProductName() << "</p>"
+ << "<h3>Screens</h3><p>High DPI scale factor rounding policy: "
+ << highDpiScaleFactorRoundingPolicy() << "</p><ol>";
+ const auto screens = QGuiApplication::screens();
+ for (auto screen : screens) {
+ const bool current = screen == this->screen();
+ str << "<li>";
+ if (current)
+ str << "<i>";
+ str << '"' << screen->name() << "\" " << screen->geometry() << ", "
+ << screen->logicalDotsPerInchX() << "DPI, DPR="
+ << screen->devicePixelRatio();
+ if (current)
+ str << "</i>";
+ str << "</li>";
+ }
+ str << "</ol></body></html>";
+ systemInfoTextBrowser->setHtml(systemInfo);
+}
+
+void WidgetGallery::helpOnCurrentWidget()
+{
+ // Skip over internal widgets
+ for (auto w = QApplication::widgetAt(QCursor::pos(screen())); w; w = w->parentWidget()) {
+ const QString name = w->objectName();
+ if (!name.isEmpty() && !name.startsWith(QLatin1String("qt_"))) {
+ launchHelp(w);
+ break;
+ }
+ }
+}
diff --git a/examples/xml/saxbookmarks/mainwindow.h b/examples/widgets/gallery/widgetgallery.h
index 20a11bb202..419c925190 100644
--- a/examples/xml/saxbookmarks/mainwindow.h
+++ b/examples/widgets/gallery/widgetgallery.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,33 +48,43 @@
**
****************************************************************************/
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
+#ifndef WIDGETGALLERY_H
+#define WIDGETGALLERY_H
-#include <QMainWindow>
+#include <QDialog>
QT_BEGIN_NAMESPACE
-class QTreeWidget;
+class QGroupBox;
+class QProgressBar;
+class QTabWidget;
+class QTextBrowser;
+class QToolBox;
QT_END_NAMESPACE
-class MainWindow : public QMainWindow
+class WidgetGallery : public QDialog
{
Q_OBJECT
public:
- MainWindow();
+ explicit WidgetGallery(QWidget *parent = nullptr);
+
+ void setVisible(bool visible) override;
+
+private slots:
+ void changeStyle(const QString &styleName);
+ void advanceProgressBar();
+ void helpOnCurrentWidget();
+ void updateSystemInfo();
-public slots:
- void open();
- void saveAs();
- void about();
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
- void onCustomContextMenuRequested(const QPoint &pos);
-#endif
private:
- void createMenus();
+ static QGroupBox *createButtonsGroupBox();
+ static QTabWidget *createItemViewTabWidget();
+ static QGroupBox *createSimpleInputWidgetsGroupBox();
+ QToolBox *createTextToolBox();
+ QProgressBar *createProgressBar();
- QTreeWidget *treeWidget;
+ QProgressBar *progressBar;
+ QTextBrowser *systemInfoTextBrowser;
};
-#endif
+#endif // WIDGETGALLERY_H
diff --git a/examples/widgets/graphicsview/boxes/scene.h b/examples/widgets/graphicsview/boxes/scene.h
index 5d65dc71e2..31bc3d7b66 100644
--- a/examples/widgets/graphicsview/boxes/scene.h
+++ b/examples/widgets/graphicsview/boxes/scene.h
@@ -215,7 +215,6 @@ private:
void initGL();
QPointF pixelPosToViewPos(const QPointF& p);
- QTime m_time; // ### Qt 6: remove (unused)
int m_lastTime;
int m_mouseEventTime;
int m_distExp;
diff --git a/examples/widgets/graphicsview/chip/view.cpp b/examples/widgets/graphicsview/chip/view.cpp
index d6fec778c2..3b1718bdbd 100644
--- a/examples/widgets/graphicsview/chip/view.cpp
+++ b/examples/widgets/graphicsview/chip/view.cpp
@@ -234,11 +234,11 @@ void View::setupMatrix()
{
qreal scale = qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50));
- QMatrix matrix;
+ QTransform matrix;
matrix.scale(scale, scale);
matrix.rotate(rotateSlider->value());
- graphicsView->setMatrix(matrix);
+ graphicsView->setTransform(matrix);
setResetButtonEnabled();
}
diff --git a/examples/widgets/graphicsview/collidingmice/main.cpp b/examples/widgets/graphicsview/collidingmice/main.cpp
index ef6d6cca64..c9ad90260f 100644
--- a/examples/widgets/graphicsview/collidingmice/main.cpp
+++ b/examples/widgets/graphicsview/collidingmice/main.cpp
@@ -58,6 +58,9 @@ static constexpr int MouseCount = 7;
//! [0]
int main(int argc, char **argv)
{
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
//! [0]
diff --git a/examples/widgets/graphicsview/diagramscene/main.cpp b/examples/widgets/graphicsview/diagramscene/main.cpp
index eefaa86554..3e321259c5 100644
--- a/examples/widgets/graphicsview/diagramscene/main.cpp
+++ b/examples/widgets/graphicsview/diagramscene/main.cpp
@@ -55,6 +55,9 @@
int main(int argv, char *args[])
{
Q_INIT_RESOURCE(diagramscene);
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argv, args);
MainWindow mainWindow;
diff --git a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
index 3327d4d5df..58b959dd10 100644
--- a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
+++ b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
@@ -113,13 +113,14 @@ void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button)
//! [1]
//! [2]
-void MainWindow::buttonGroupClicked(int id)
+void MainWindow::buttonGroupClicked(QAbstractButton *button)
{
const QList<QAbstractButton *> buttons = buttonGroup->buttons();
- for (QAbstractButton *button : buttons) {
- if (buttonGroup->button(id) != button)
+ for (QAbstractButton *myButton : buttons) {
+ if (myButton != button)
button->setChecked(false);
}
+ const int id = buttonGroup->id(button);
if (id == InsertTextButton) {
scene->setMode(DiagramScene::InsertText);
} else {
@@ -154,7 +155,7 @@ void MainWindow::deleteItem()
//! [3]
//! [4]
-void MainWindow::pointerGroupClicked(int)
+void MainWindow::pointerGroupClicked()
{
scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
}
@@ -231,8 +232,8 @@ void MainWindow::fontSizeChanged(const QString &)
void MainWindow::sceneScaleChanged(const QString &scale)
{
double newScale = scale.left(scale.indexOf(tr("%"))).toDouble() / 100.0;
- QMatrix oldMatrix = view->matrix();
- view->resetMatrix();
+ QTransform oldMatrix = view->transform();
+ view->resetTransform();
view->translate(oldMatrix.dx(), oldMatrix.dy());
view->scale(newScale, newScale);
}
@@ -334,7 +335,7 @@ void MainWindow::createToolBox()
{
buttonGroup = new QButtonGroup(this);
buttonGroup->setExclusive(false);
- connect(buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
+ connect(buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
this, &MainWindow::buttonGroupClicked);
QGridLayout *layout = new QGridLayout;
layout->addWidget(createCellWidget(tr("Conditional"), DiagramItem::Conditional), 0, 0);
@@ -528,7 +529,7 @@ void MainWindow::createToolbars()
pointerTypeGroup = new QButtonGroup(this);
pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem));
pointerTypeGroup->addButton(linePointerButton, int(DiagramScene::InsertLine));
- connect(pointerTypeGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
+ connect(pointerTypeGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
this, &MainWindow::pointerGroupClicked);
sceneScaleCombo = new QComboBox;
diff --git a/examples/widgets/graphicsview/diagramscene/mainwindow.h b/examples/widgets/graphicsview/diagramscene/mainwindow.h
index e04224fbc7..9fcd1884ca 100644
--- a/examples/widgets/graphicsview/diagramscene/mainwindow.h
+++ b/examples/widgets/graphicsview/diagramscene/mainwindow.h
@@ -82,9 +82,9 @@ public:
private slots:
void backgroundButtonGroupClicked(QAbstractButton *button);
- void buttonGroupClicked(int id);
+ void buttonGroupClicked(QAbstractButton *button);
void deleteItem();
- void pointerGroupClicked(int id);
+ void pointerGroupClicked();
void bringToFront();
void sendToBack();
void itemInserted(DiagramItem *item);
diff --git a/examples/widgets/graphicsview/embeddeddialogs/customproxy.h b/examples/widgets/graphicsview/embeddeddialogs/customproxy.h
index d7df2b7b4b..5aa0250a29 100644
--- a/examples/widgets/graphicsview/embeddeddialogs/customproxy.h
+++ b/examples/widgets/graphicsview/embeddeddialogs/customproxy.h
@@ -59,7 +59,7 @@ class CustomProxy : public QGraphicsProxyWidget
Q_OBJECT
public:
- explicit CustomProxy(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = nullptr);
+ explicit CustomProxy(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = { });
QRectF boundingRect() const override;
void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
diff --git a/examples/widgets/graphicsview/flowlayout/window.cpp b/examples/widgets/graphicsview/flowlayout/window.cpp
index 8fe06d0e11..0edaa686b4 100644
--- a/examples/widgets/graphicsview/flowlayout/window.cpp
+++ b/examples/widgets/graphicsview/flowlayout/window.cpp
@@ -59,7 +59,7 @@ Window::Window(QGraphicsItem *parent) : QGraphicsWidget(parent, Qt::Window)
FlowLayout *lay = new FlowLayout;
const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown."
" I am bothered when I do not know others. (Confucius)"));
- const QVector<QStringRef> words = sentence.splitRef(QLatin1Char(' '), QString::SkipEmptyParts);
+ const QVector<QStringRef> words = sentence.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts);
for (const QStringRef &word : words) {
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
QLabel *label = new QLabel(word.toString());
diff --git a/examples/widgets/itemviews/addressbook/main.cpp b/examples/widgets/itemviews/addressbook/main.cpp
index 0731287cdd..86a11c5850 100644
--- a/examples/widgets/itemviews/addressbook/main.cpp
+++ b/examples/widgets/itemviews/addressbook/main.cpp
@@ -55,6 +55,9 @@
//! [0]
int main(int argc, char *argv[])
{
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
MainWindow mw;
mw.show();
diff --git a/examples/widgets/itemviews/chart/mainwindow.cpp b/examples/widgets/itemviews/chart/mainwindow.cpp
index 53f57fbb49..671cfb1941 100644
--- a/examples/widgets/itemviews/chart/mainwindow.cpp
+++ b/examples/widgets/itemviews/chart/mainwindow.cpp
@@ -134,7 +134,7 @@ void MainWindow::loadFile(const QString &fileName)
if (!line.isEmpty()) {
model->insertRows(row, 1, QModelIndex());
- const QStringList pieces = line.split(',', QString::SkipEmptyParts);
+ const QStringList pieces = line.split(QLatin1Char(','), Qt::SkipEmptyParts);
if (pieces.size() < 3)
continue;
model->setData(model->index(row, 0, QModelIndex()),
diff --git a/examples/widgets/itemviews/coloreditorfactory/window.cpp b/examples/widgets/itemviews/coloreditorfactory/window.cpp
index e4a9379d8f..25e196a80c 100644
--- a/examples/widgets/itemviews/coloreditorfactory/window.cpp
+++ b/examples/widgets/itemviews/coloreditorfactory/window.cpp
@@ -61,7 +61,7 @@ Window::Window()
QItemEditorCreatorBase *colorListCreator =
new QStandardItemEditorCreator<ColorListEditor>();
- factory->registerEditor(QVariant::Color, colorListCreator);
+ factory->registerEditor(QMetaType::QColor, colorListCreator);
QItemEditorFactory::setDefaultFactory(factory);
diff --git a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
index 430a086fd6..fd17876f2b 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
+++ b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
@@ -98,7 +98,7 @@ bool MySortFilterProxyModel::lessThan(const QModelIndex &left,
//! [4]
//! [6]
- if (leftData.type() == QVariant::DateTime) {
+ if (leftData.userType() == QMetaType::QDateTime) {
return leftData.toDateTime() < rightData.toDateTime();
} else {
static const QRegularExpression emailPattern("[\\w\\.]*@[\\w\\.]*");
diff --git a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
index 836c2e8651..9678e45be7 100644
--- a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
@@ -267,7 +267,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
if (!lineData.isEmpty()) {
// Read the column data from the rest of the line.
- const QStringList columnStrings = lineData.split('\t', QString::SkipEmptyParts);
+ const QStringList columnStrings =
+ lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts);
QVector<QVariant> columnData;
columnData.reserve(columnStrings.size());
for (const QString &columnString : columnStrings)
diff --git a/examples/widgets/itemviews/simpletreemodel/treemodel.cpp b/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
index cfa65846ed..28640d6433 100644
--- a/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
+++ b/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
@@ -194,7 +194,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
if (!lineData.isEmpty()) {
// Read the column data from the rest of the line.
- const QStringList columnStrings = lineData.split('\t', QString::SkipEmptyParts);
+ const QStringList columnStrings =
+ lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts);
QVector<QVariant> columnData;
columnData.reserve(columnStrings.count());
for (const QString &columnString : columnStrings)
diff --git a/examples/widgets/itemviews/spreadsheet/main.cpp b/examples/widgets/itemviews/spreadsheet/main.cpp
index 548dc8d604..968312d097 100644
--- a/examples/widgets/itemviews/spreadsheet/main.cpp
+++ b/examples/widgets/itemviews/spreadsheet/main.cpp
@@ -56,6 +56,10 @@
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(spreadsheet);
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
+
QApplication app(argc, argv);
SpreadSheet sheet(10, 6);
sheet.setWindowIcon(QPixmap(":/images/interview.png"));
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
index eadd5fadb8..ad80a238aa 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
@@ -53,7 +53,7 @@
#include <QtWidgets>
SpreadSheetDelegate::SpreadSheetDelegate(QObject *parent)
- : QItemDelegate(parent)
+ : QStyledItemDelegate(parent)
{}
QWidget *SpreadSheetDelegate::createEditor(QWidget *parent,
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h
index c89459cadf..36c70d2391 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h
@@ -51,9 +51,9 @@
#ifndef SPREADSHEETDELEGATE_H
#define SPREADSHEETDELEGATE_H
-#include <QItemDelegate>
+#include <QStyledItemDelegate>
-class SpreadSheetDelegate : public QItemDelegate
+class SpreadSheetDelegate : public QStyledItemDelegate
{
Q_OBJECT
diff --git a/examples/widgets/layouts/basiclayouts/main.cpp b/examples/widgets/layouts/basiclayouts/main.cpp
index f59de1d385..cf0ff0a535 100644
--- a/examples/widgets/layouts/basiclayouts/main.cpp
+++ b/examples/widgets/layouts/basiclayouts/main.cpp
@@ -56,7 +56,11 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Dialog dialog;
+#ifdef Q_OS_ANDROID
+ dialog.showMaximized();
+#else
dialog.show();
+#endif
return app.exec();
}
diff --git a/examples/widgets/layouts/dynamiclayouts/main.cpp b/examples/widgets/layouts/dynamiclayouts/main.cpp
index 9959c472f4..cf0ff0a535 100644
--- a/examples/widgets/layouts/dynamiclayouts/main.cpp
+++ b/examples/widgets/layouts/dynamiclayouts/main.cpp
@@ -56,6 +56,11 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Dialog dialog;
+#ifdef Q_OS_ANDROID
+ dialog.showMaximized();
+#else
dialog.show();
+#endif
+
return app.exec();
}
diff --git a/examples/widgets/layouts/flowlayout/flowlayout.cpp b/examples/widgets/layouts/flowlayout/flowlayout.cpp
index 5c59ae025c..9a488557cf 100644
--- a/examples/widgets/layouts/flowlayout/flowlayout.cpp
+++ b/examples/widgets/layouts/flowlayout/flowlayout.cpp
@@ -123,7 +123,7 @@ QLayoutItem *FlowLayout::takeAt(int index)
//! [6]
Qt::Orientations FlowLayout::expandingDirections() const
{
- return 0;
+ return { };
}
//! [6]
diff --git a/examples/widgets/mainwindows/application/main.cpp b/examples/widgets/mainwindows/application/main.cpp
index 78db7134a3..b46e1116dc 100644
--- a/examples/widgets/mainwindows/application/main.cpp
+++ b/examples/widgets/mainwindows/application/main.cpp
@@ -58,6 +58,9 @@
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(application);
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("QtProject");
diff --git a/examples/widgets/mainwindows/dockwidgets/main.cpp b/examples/widgets/mainwindows/dockwidgets/main.cpp
index ff3ba506a8..bf3ad9bcf7 100644
--- a/examples/widgets/mainwindows/dockwidgets/main.cpp
+++ b/examples/widgets/mainwindows/dockwidgets/main.cpp
@@ -54,6 +54,9 @@
int main(int argc, char *argv[])
{
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
Q_INIT_RESOURCE(dockwidgets);
MainWindow mainWin;
diff --git a/examples/widgets/mainwindows/mainwindow/colorswatch.h b/examples/widgets/mainwindows/mainwindow/colorswatch.h
index 7f73e46f31..2bd9fd2891 100644
--- a/examples/widgets/mainwindows/mainwindow/colorswatch.h
+++ b/examples/widgets/mainwindows/mainwindow/colorswatch.h
@@ -62,7 +62,7 @@ class ColorSwatch : public QDockWidget
Q_OBJECT
public:
- explicit ColorSwatch(const QString &colorName, QMainWindow *parent = nullptr, Qt::WindowFlags flags = 0);
+ explicit ColorSwatch(const QString &colorName, QMainWindow *parent = nullptr, Qt::WindowFlags flags = { });
void setCustomSizeHint(const QSize &size);
QMenu *colorSwatchMenu() const { return menu; }
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
index 4ba180f312..717c75b166 100644
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
+++ b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
@@ -120,7 +120,7 @@ void MainWindow::actionTriggered(QAction *action)
void MainWindow::setupToolBar()
{
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MACOS
setUnifiedTitleAndToolBarOnMac(true);
#endif
@@ -178,7 +178,7 @@ void MainWindow::setupMenuBar()
for (int i = 0; i < toolBars.count(); ++i)
toolBarMenu->addMenu(toolBars.at(i)->toolbarMenu());
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MACOS
toolBarMenu->addSeparator();
action = toolBarMenu->addAction(tr("Unified"));
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.h b/examples/widgets/mainwindows/mainwindow/mainwindow.h
index a2c9d30ded..3ce9732763 100644
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.h
+++ b/examples/widgets/mainwindows/mainwindow/mainwindow.h
@@ -65,7 +65,7 @@ public:
explicit MainWindow(const CustomSizeHintMap &customSizeHints,
QWidget *parent = nullptr,
- Qt::WindowFlags flags = 0);
+ Qt::WindowFlags flags = { });
public slots:
void actionTriggered(QAction *action);
diff --git a/examples/widgets/painting/affine/main.cpp b/examples/widgets/painting/affine/main.cpp
index 6ce8efe482..641fc5c204 100644
--- a/examples/widgets/painting/affine/main.cpp
+++ b/examples/widgets/painting/affine/main.cpp
@@ -55,7 +55,9 @@
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(affine);
-
+#ifdef Q_OS_ANDROID
+ qputenv("QT_SCALE_FACTOR", "2");
+#endif
QApplication app(argc, argv);
XFormWidget xformWidget(nullptr);
diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp
index 50acf0f814..d7ed2125d2 100644
--- a/examples/widgets/painting/affine/xform.cpp
+++ b/examples/widgets/painting/affine/xform.cpp
@@ -223,7 +223,7 @@ void XFormView::setRotation(qreal r)
m_rotation = r;
QPointF center(pts->points().at(0));
- QMatrix m;
+ QTransform m;
m.translate(center.x(), center.y());
m.rotate(m_rotation - old_rot);
m.translate(-center.x(), -center.y());
@@ -236,7 +236,7 @@ void XFormView::timerEvent(QTimerEvent *e)
{
if (e->timerId() == timer.timerId()) {
QPointF center(pts->points().at(0));
- QMatrix m;
+ QTransform m;
m.translate(center.x(), center.y());
m.rotate(0.2);
m.translate(-center.x(), -center.y());
@@ -787,8 +787,8 @@ XFormWidget::XFormWidget(QWidget *parent)
view = new XFormView(this);
view->setMinimumSize(200, 200);
- QGroupBox *mainGroup = new QGroupBox(this);
- mainGroup->setFixedWidth(180);
+ QWidget *mainContentWidget = new QWidget();
+ QGroupBox *mainGroup = new QGroupBox(mainContentWidget);
mainGroup->setTitle(tr("Affine Transformations"));
QGroupBox *rotateGroup = new QGroupBox(mainGroup);
@@ -837,10 +837,6 @@ XFormWidget::XFormWidget(QWidget *parent)
whatsThisButton->setText(tr("What's This?"));
whatsThisButton->setCheckable(true);
- QHBoxLayout *viewLayout = new QHBoxLayout(this);
- viewLayout->addWidget(view);
- viewLayout->addWidget(mainGroup);
-
QVBoxLayout *rotateGroupLayout = new QVBoxLayout(rotateGroup);
rotateGroupLayout->addWidget(rotateSlider);
@@ -871,6 +867,20 @@ XFormWidget::XFormWidget(QWidget *parent)
#endif
mainGroupLayout->addWidget(whatsThisButton);
+ mainGroup->setLayout(mainGroupLayout);
+
+ QVBoxLayout *mainContentLayout = new QVBoxLayout();
+ mainContentLayout->addWidget(mainGroup);
+ mainContentWidget->setLayout(mainContentLayout);
+
+ QScrollArea *mainScrollArea = new QScrollArea();
+ mainScrollArea->setWidget(mainContentWidget);
+ mainScrollArea->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+
+ QHBoxLayout *viewLayout = new QHBoxLayout(this);
+ viewLayout->addWidget(view);
+ viewLayout->addWidget(mainScrollArea);
+
connect(rotateSlider, &QSlider::valueChanged, view, &XFormView::changeRotation);
connect(shearSlider, &QSlider::valueChanged, view, &XFormView::changeShear);
connect(scaleSlider, &QSlider::valueChanged, view, &XFormView::changeScale);
diff --git a/examples/widgets/painting/basicdrawing/renderarea.cpp b/examples/widgets/painting/basicdrawing/renderarea.cpp
index a1437dea8f..09d610ee95 100644
--- a/examples/widgets/painting/basicdrawing/renderarea.cpp
+++ b/examples/widgets/painting/basicdrawing/renderarea.cpp
@@ -51,6 +51,7 @@
#include "renderarea.h"
#include <QPainter>
+#include <QPainterPath>
//! [0]
RenderArea::RenderArea(QWidget *parent)
diff --git a/examples/widgets/painting/concentriccircles/main.cpp b/examples/widgets/painting/concentriccircles/main.cpp
index d9fa2879c4..00456195d9 100644
--- a/examples/widgets/painting/concentriccircles/main.cpp
+++ b/examples/widgets/painting/concentriccircles/main.cpp
@@ -54,6 +54,9 @@
int main(int argc, char *argv[])
{
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
Window window;
window.show();
diff --git a/examples/widgets/painting/deform/pathdeform.cpp b/examples/widgets/painting/deform/pathdeform.cpp
index d5c8746247..961d5e5e99 100644
--- a/examples/widgets/painting/deform/pathdeform.cpp
+++ b/examples/widgets/painting/deform/pathdeform.cpp
@@ -374,7 +374,7 @@ void PathDeformRenderer::setText(const QString &text)
}
for (int i=0; i<m_paths.size(); ++i)
- m_paths[i] = m_paths[i] * QMatrix(1, 0, 0, 1, -m_pathBounds.x(), -m_pathBounds.y());
+ m_paths[i] = m_paths[i] * QTransform(1, 0, 0, 1, -m_pathBounds.x(), -m_pathBounds.y());
update();
}
diff --git a/examples/widgets/painting/fontsampler/main.cpp b/examples/widgets/painting/fontsampler/main.cpp
index 1bf46b226f..cec6929827 100644
--- a/examples/widgets/painting/fontsampler/main.cpp
+++ b/examples/widgets/painting/fontsampler/main.cpp
@@ -54,6 +54,9 @@
int main(int argc, char *argv[])
{
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
MainWindow window;
window.show();
diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp
index d62ae93a15..cb1a0177e9 100644
--- a/examples/widgets/painting/gradients/gradients.cpp
+++ b/examples/widgets/painting/gradients/gradients.cpp
@@ -282,7 +282,8 @@ GradientWidget::GradientWidget(QWidget *parent)
m_renderer = new GradientRenderer(this);
- QGroupBox *mainGroup = new QGroupBox(this);
+ QWidget *mainContentWidget = new QWidget();
+ QGroupBox *mainGroup = new QGroupBox(mainContentWidget);
mainGroup->setTitle(tr("Gradients"));
QGroupBox *editorGroup = new QGroupBox(mainGroup);
@@ -327,11 +328,6 @@ GradientWidget::GradientWidget(QWidget *parent)
whatsThisButton->setText(tr("What's This?"));
whatsThisButton->setCheckable(true);
- // Layouts
- QHBoxLayout *mainLayout = new QHBoxLayout(this);
- mainLayout->addWidget(m_renderer);
- mainLayout->addWidget(mainGroup);
-
mainGroup->setFixedWidth(200);
QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup);
mainGroupLayout->addWidget(editorGroup);
@@ -370,6 +366,21 @@ GradientWidget::GradientWidget(QWidget *parent)
defaultsGroupLayout->addWidget(default3Button);
editorGroupLayout->addWidget(default4Button);
+ mainGroup->setLayout(mainGroupLayout);
+
+ QVBoxLayout *mainContentLayout = new QVBoxLayout();
+ mainContentLayout->addWidget(mainGroup);
+ mainContentWidget->setLayout(mainContentLayout);
+
+ QScrollArea *mainScrollArea = new QScrollArea();
+ mainScrollArea->setWidget(mainContentWidget);
+ mainScrollArea->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+
+ // Layouts
+ QHBoxLayout *mainLayout = new QHBoxLayout(this);
+ mainLayout->addWidget(m_renderer);
+ mainLayout->addWidget(mainScrollArea);
+
connect(m_editor, &GradientEditor::gradientStopsChanged,
m_renderer, &GradientRenderer::setGradientStops);
connect(m_linearButton, &QRadioButton::clicked,
diff --git a/examples/widgets/painting/gradients/main.cpp b/examples/widgets/painting/gradients/main.cpp
index 0ddf7a4579..7ffb0326e9 100644
--- a/examples/widgets/painting/gradients/main.cpp
+++ b/examples/widgets/painting/gradients/main.cpp
@@ -55,6 +55,9 @@
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(gradients);
+#ifdef Q_OS_ANDROID
+ qputenv("QT_SCALE_FACTOR", "2");
+#endif
QApplication app(argc, argv);
diff --git a/examples/widgets/painting/pathstroke/main.cpp b/examples/widgets/painting/pathstroke/main.cpp
index 57c85d73a3..35317480a3 100644
--- a/examples/widgets/painting/pathstroke/main.cpp
+++ b/examples/widgets/painting/pathstroke/main.cpp
@@ -55,6 +55,9 @@
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(pathstroke);
+#ifdef Q_OS_ANDROID
+ qputenv("QT_SCALE_FACTOR", "2");
+#endif
QApplication app(argc, argv);
diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp
index a850ce2672..7dab6f95a2 100644
--- a/examples/widgets/painting/pathstroke/pathstroke.cpp
+++ b/examples/widgets/painting/pathstroke/pathstroke.cpp
@@ -511,10 +511,10 @@ void PathStrokeRenderer::initializePoints()
m_points.clear();
m_vectors.clear();
- QMatrix m;
+ QTransform m;
qreal rot = 360.0 / count;
QPointF center(width() / 2, height() / 2);
- QMatrix vm;
+ QTransform vm;
vm.shear(2, -1);
vm.scale(3, 3);
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
index c9173bcb99..cf3eb47ad8 100644
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ b/examples/widgets/richtext/textedit/textedit.cpp
@@ -96,7 +96,7 @@ const QString rsrcPath = ":/images/win";
TextEdit::TextEdit(QWidget *parent)
: QMainWindow(parent)
{
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MACOS
setUnifiedTitleAndToolBarOnMac(true);
#endif
setWindowTitle(QCoreApplication::applicationName());
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
index ea3cb00a02..6398098eee 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
@@ -286,7 +286,7 @@ void RegularExpressionDialog::refresh()
setResultUiEnabled(true);
- QRegularExpression::MatchType matchType = matchTypeComboBox->currentData().value<QRegularExpression::MatchType>();
+ QRegularExpression::MatchType matchType = qvariant_cast<QRegularExpression::MatchType>(matchTypeComboBox->currentData());
QRegularExpression::PatternOptions patternOptions = QRegularExpression::NoPatternOption;
QRegularExpression::MatchOptions matchOptions = QRegularExpression::NoMatchOption;
diff --git a/examples/widgets/tools/settingseditor/mainwindow.cpp b/examples/widgets/tools/settingseditor/mainwindow.cpp
index ccca16ffcd..225a396f91 100644
--- a/examples/widgets/tools/settingseditor/mainwindow.cpp
+++ b/examples/widgets/tools/settingseditor/mainwindow.cpp
@@ -157,10 +157,10 @@ void MainWindow::createActions()
QAction *openIniFileAct = fileMenu->addAction(tr("Open I&NI File..."), this, &MainWindow::openIniFile);
openIniFileAct->setShortcut(tr("Ctrl+N"));
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MACOS
QAction *openPropertyListAct = fileMenu->addAction(tr("Open Apple &Property List..."), this, &MainWindow::openPropertyList);
openPropertyListAct->setShortcut(tr("Ctrl+P"));
-#endif // Q_OS_OSX
+#endif // Q_OS_MACOS
#ifdef Q_OS_WIN
QAction *openRegistryPathAct = fileMenu->addAction(tr("Open Windows &Registry Path..."), this, &MainWindow::openRegistryPath);
diff --git a/examples/widgets/tools/settingseditor/settingstree.cpp b/examples/widgets/tools/settingseditor/settingstree.cpp
index 49d299bf72..9132368e4a 100644
--- a/examples/widgets/tools/settingseditor/settingstree.cpp
+++ b/examples/widgets/tools/settingseditor/settingstree.cpp
@@ -208,7 +208,7 @@ void SettingsTree::updateChildItems(QTreeWidgetItem *parent)
}
QVariant value = settings->value(key);
- if (value.type() == QVariant::Invalid) {
+ if (value.userType() == QMetaType::UnknownType) {
child->setText(1, "Invalid");
} else {
child->setText(1, value.typeName());
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.cpp b/examples/widgets/tools/settingseditor/variantdelegate.cpp
index 9772fe8a41..eb822f0dc2 100644
--- a/examples/widgets/tools/settingseditor/variantdelegate.cpp
+++ b/examples/widgets/tools/settingseditor/variantdelegate.cpp
@@ -81,7 +81,7 @@ void VariantDelegate::paint(QPainter *painter,
{
if (index.column() == 2) {
QVariant value = index.model()->data(index, Qt::UserRole);
- if (!isSupportedType(value.type())) {
+ if (!isSupportedType(value.userType())) {
QStyleOptionViewItem myOption = option;
myOption.state &= ~QStyle::State_Enabled;
QStyledItemDelegate::paint(painter, myOption, index);
@@ -100,7 +100,7 @@ QWidget *VariantDelegate::createEditor(QWidget *parent,
return nullptr;
QVariant originalValue = index.model()->data(index, Qt::UserRole);
- if (!isSupportedType(originalValue.type()))
+ if (!isSupportedType(originalValue.userType()))
return nullptr;
QLineEdit *lineEdit = new QLineEdit(parent);
@@ -108,46 +108,46 @@ QWidget *VariantDelegate::createEditor(QWidget *parent,
QRegularExpression regExp;
- switch (originalValue.type()) {
- case QVariant::Bool:
+ switch (originalValue.userType()) {
+ case QMetaType::Bool:
regExp = boolExp;
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
regExp = byteArrayExp;
break;
- case QVariant::Char:
+ case QMetaType::QChar:
regExp = charExp;
break;
- case QVariant::Color:
+ case QMetaType::QColor:
regExp = colorExp;
break;
- case QVariant::Date:
+ case QMetaType::QDate:
regExp = dateExp;
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
regExp = dateTimeExp;
break;
- case QVariant::Double:
+ case QMetaType::Double:
regExp = doubleExp;
break;
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
regExp = signedIntegerExp;
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
regExp = pointExp;
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
regExp = rectExp;
break;
- case QVariant::Size:
+ case QMetaType::QSize:
regExp = sizeExp;
break;
- case QVariant::Time:
+ case QMetaType::QTime:
regExp = timeExp;
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
regExp = unsignedIntegerExp;
break;
default:
@@ -189,18 +189,18 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
QVariant value;
QRegularExpressionMatch match;
- switch (originalValue.type()) {
- case QVariant::Char:
+ switch (originalValue.userType()) {
+ case QMetaType::QChar:
value = text.at(0);
break;
- case QVariant::Color:
+ case QMetaType::QColor:
match = colorExp.match(text);
value = QColor(qMin(match.captured(1).toInt(), 255),
qMin(match.captured(2).toInt(), 255),
qMin(match.captured(3).toInt(), 255),
qMin(match.captured(4).toInt(), 255));
break;
- case QVariant::Date:
+ case QMetaType::QDate:
{
QDate date = QDate::fromString(text, Qt::ISODate);
if (!date.isValid())
@@ -208,7 +208,7 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
value = date;
}
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
{
QDateTime dateTime = QDateTime::fromString(text, Qt::ISODate);
if (!dateTime.isValid())
@@ -216,23 +216,23 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
value = dateTime;
}
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
match = pointExp.match(text);
value = QPoint(match.captured(1).toInt(), match.captured(2).toInt());
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
match = rectExp.match(text);
value = QRect(match.captured(1).toInt(), match.captured(2).toInt(),
match.captured(3).toInt(), match.captured(4).toInt());
break;
- case QVariant::Size:
+ case QMetaType::QSize:
match = sizeExp.match(text);
value = QSize(match.captured(1).toInt(), match.captured(2).toInt());
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
value = text.split(',');
break;
- case QVariant::Time:
+ case QMetaType::QTime:
{
QTime time = QTime::fromString(text, Qt::ISODate);
if (!time.isValid())
@@ -242,33 +242,33 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
break;
default:
value = text;
- value.convert(originalValue.type());
+ value.convert(originalValue.userType());
}
model->setData(index, displayText(value), Qt::DisplayRole);
model->setData(index, value, Qt::UserRole);
}
-bool VariantDelegate::isSupportedType(QVariant::Type type)
+bool VariantDelegate::isSupportedType(int type)
{
switch (type) {
- case QVariant::Bool:
- case QVariant::ByteArray:
- case QVariant::Char:
- case QVariant::Color:
- case QVariant::Date:
- case QVariant::DateTime:
- case QVariant::Double:
- case QVariant::Int:
- case QVariant::LongLong:
- case QVariant::Point:
- case QVariant::Rect:
- case QVariant::Size:
- case QVariant::String:
- case QVariant::StringList:
- case QVariant::Time:
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::Bool:
+ case QMetaType::QByteArray:
+ case QMetaType::QChar:
+ case QMetaType::QColor:
+ case QMetaType::QDate:
+ case QMetaType::QDateTime:
+ case QMetaType::Double:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
+ case QMetaType::QPoint:
+ case QMetaType::QRect:
+ case QMetaType::QSize:
+ case QMetaType::QString:
+ case QMetaType::QStringList:
+ case QMetaType::QTime:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
return true;
default:
return false;
@@ -277,50 +277,50 @@ bool VariantDelegate::isSupportedType(QVariant::Type type)
QString VariantDelegate::displayText(const QVariant &value)
{
- switch (value.type()) {
- case QVariant::Bool:
- case QVariant::ByteArray:
- case QVariant::Char:
- case QVariant::Double:
- case QVariant::Int:
- case QVariant::LongLong:
- case QVariant::String:
- case QVariant::UInt:
- case QVariant::ULongLong:
+ switch (value.userType()) {
+ case QMetaType::Bool:
+ case QMetaType::QByteArray:
+ case QMetaType::QChar:
+ case QMetaType::Double:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
+ case QMetaType::QString:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
return value.toString();
- case QVariant::Color:
+ case QMetaType::QColor:
{
QColor color = qvariant_cast<QColor>(value);
return QString("(%1,%2,%3,%4)")
.arg(color.red()).arg(color.green())
.arg(color.blue()).arg(color.alpha());
}
- case QVariant::Date:
+ case QMetaType::QDate:
return value.toDate().toString(Qt::ISODate);
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return value.toDateTime().toString(Qt::ISODate);
- case QVariant::Invalid:
+ case QMetaType::UnknownType:
return "<Invalid>";
- case QVariant::Point:
+ case QMetaType::QPoint:
{
QPoint point = value.toPoint();
return QString("(%1,%2)").arg(point.x()).arg(point.y());
}
- case QVariant::Rect:
+ case QMetaType::QRect:
{
QRect rect = value.toRect();
return QString("(%1,%2,%3,%4)")
.arg(rect.x()).arg(rect.y())
.arg(rect.width()).arg(rect.height());
}
- case QVariant::Size:
+ case QMetaType::QSize:
{
QSize size = value.toSize();
return QString("(%1,%2)").arg(size.width()).arg(size.height());
}
- case QVariant::StringList:
+ case QMetaType::QStringList:
return value.toStringList().join(',');
- case QVariant::Time:
+ case QMetaType::QTime:
return value.toTime().toString(Qt::ISODate);
default:
break;
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.h b/examples/widgets/tools/settingseditor/variantdelegate.h
index 68f21fa3f6..96e44fd181 100644
--- a/examples/widgets/tools/settingseditor/variantdelegate.h
+++ b/examples/widgets/tools/settingseditor/variantdelegate.h
@@ -69,7 +69,7 @@ public:
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const override;
- static bool isSupportedType(QVariant::Type type);
+ static bool isSupportedType(int type);
static QString displayText(const QVariant &value);
private:
diff --git a/examples/widgets/tools/undo/main.cpp b/examples/widgets/tools/undo/main.cpp
index a5ec1b1b83..1a6dcf8c48 100644
--- a/examples/widgets/tools/undo/main.cpp
+++ b/examples/widgets/tools/undo/main.cpp
@@ -54,6 +54,9 @@
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(undo);
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
diff --git a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp b/examples/widgets/tutorials/addressbook/part7/addressbook.cpp
index 717d0882af..1ba23756c4 100644
--- a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp
+++ b/examples/widgets/tutorials/addressbook/part7/addressbook.cpp
@@ -413,7 +413,7 @@ void AddressBook::exportAsVCard()
int index = name.indexOf(" ");
if (index != -1) {
- nameList = name.split(QRegularExpression("\\s+"), QString::SkipEmptyParts);
+ nameList = name.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
firstName = nameList.first();
lastName = nameList.last();
} else {
diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro
index d975ea8307..99e1c71594 100644
--- a/examples/widgets/widgets.pro
+++ b/examples/widgets/widgets.pro
@@ -9,6 +9,7 @@ SUBDIRS = \
dialogs \
draganddrop \
effects \
+ gallery \
gestures \
graphicsview \
itemviews \
diff --git a/examples/widgets/widgets/calculator/main.cpp b/examples/widgets/widgets/calculator/main.cpp
index a034bb262e..5f59d00ca6 100644
--- a/examples/widgets/widgets/calculator/main.cpp
+++ b/examples/widgets/widgets/calculator/main.cpp
@@ -54,6 +54,9 @@
int main(int argc, char *argv[])
{
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
Calculator calc;
calc.show();
diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp
index b0f9705c21..702b50156b 100644
--- a/examples/widgets/widgets/charactermap/mainwindow.cpp
+++ b/examples/widgets/widgets/charactermap/mainwindow.cpp
@@ -201,7 +201,7 @@ void MainWindow::findStyles(const QFont &font)
void MainWindow::filterChanged(int f)
{
const QFontComboBox::FontFilter filter =
- filterCombo->itemData(f).value<QFontComboBox::FontFilter>();
+ qvariant_cast<QFontComboBox::FontFilter>(filterCombo->itemData(f));
fontCombo->setFontFilters(filter);
statusBar()->showMessage(tr("%n font(s) found", nullptr, fontCombo->count()));
}
diff --git a/examples/widgets/widgets/elidedlabel/main.cpp b/examples/widgets/widgets/elidedlabel/main.cpp
index 1c620c1d41..58507766e7 100644
--- a/examples/widgets/widgets/elidedlabel/main.cpp
+++ b/examples/widgets/widgets/elidedlabel/main.cpp
@@ -55,6 +55,9 @@
//! [0]
int main( int argc, char *argv[] )
{
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication application( argc, argv );
TestWidget w;
w.showFullScreen();
diff --git a/examples/widgets/widgets/icons/imagedelegate.cpp b/examples/widgets/widgets/icons/imagedelegate.cpp
index 39c2e43134..4fd251aa1b 100644
--- a/examples/widgets/widgets/icons/imagedelegate.cpp
+++ b/examples/widgets/widgets/icons/imagedelegate.cpp
@@ -55,9 +55,8 @@
//! [0]
ImageDelegate::ImageDelegate(QObject *parent)
- : QItemDelegate(parent)
-{
-}
+ : QStyledItemDelegate(parent)
+{}
//! [0]
//! [1]
diff --git a/examples/widgets/widgets/icons/imagedelegate.h b/examples/widgets/widgets/icons/imagedelegate.h
index 3b76b78339..9d65304e2c 100644
--- a/examples/widgets/widgets/icons/imagedelegate.h
+++ b/examples/widgets/widgets/icons/imagedelegate.h
@@ -51,10 +51,10 @@
#ifndef IMAGEDELEGATE_H
#define IMAGEDELEGATE_H
-#include <QItemDelegate>
+#include <QStyledItemDelegate>
//! [0]
-class ImageDelegate : public QItemDelegate
+class ImageDelegate : public QStyledItemDelegate
{
Q_OBJECT
@@ -72,7 +72,7 @@ public:
//! [1] //! [2]
private slots:
void emitCommitData();
-};
//! [2]
+};
#endif
diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp
index f342c18c4c..4f990f7320 100644
--- a/examples/widgets/widgets/icons/mainwindow.cpp
+++ b/examples/widgets/widgets/icons/mainwindow.cpp
@@ -216,16 +216,13 @@ void MainWindow::changeIcon()
QImage image(fileName);
if (!image.isNull())
icon.addPixmap(QPixmap::fromImage(image), mode, state);
-//! [8] //! [9]
+//! [8]
}
-//! [9] //! [10]
}
-//! [10]
-
//! [11]
previewArea->setIcon(icon);
-}
//! [11]
+}
void MainWindow::addSampleImages()
{
@@ -280,17 +277,15 @@ void MainWindow::loadImages(const QStringList &fileNames)
.arg(QDir::toNativeSeparators(fileInfo.absolutePath()), fileInfo.fileName())
.arg(fileInfo2x.exists() ? fileInfo2x.fileName() : tr("<None>"))
.arg(image.width()).arg(image.height());
-//! [13] //! [14]
QTableWidgetItem *fileItem = new QTableWidgetItem(imageName);
fileItem->setData(Qt::UserRole, fileName);
fileItem->setIcon(QPixmap::fromImage(image));
fileItem->setFlags((fileItem->flags() | Qt::ItemIsUserCheckable) & ~Qt::ItemIsEditable);
fileItem->setToolTip(toolTip);
-//! [14]
+//! [13]
//! [15]
QIcon::Mode mode = QIcon::Normal;
-//! [15] //! [16]
QIcon::State state = QIcon::Off;
if (guessModeStateAct->isChecked()) {
if (imageName.contains(QLatin1String("_act"), Qt::CaseInsensitive))
@@ -302,13 +297,11 @@ void MainWindow::loadImages(const QStringList &fileNames)
if (imageName.contains(QLatin1String("_on"), Qt::CaseInsensitive))
state = QIcon::On;
-//! [16] //! [17]
+//! [15]
}
-//! [17]
//! [18]
imagesTable->setItem(row, 0, fileItem);
-//! [18] //! [19]
QTableWidgetItem *modeItem =
new QTableWidgetItem(IconPreviewArea::iconModeNames().at(IconPreviewArea::iconModes().indexOf(mode)));
modeItem->setToolTip(toolTip);
@@ -321,9 +314,9 @@ void MainWindow::loadImages(const QStringList &fileNames)
imagesTable->openPersistentEditor(stateItem);
fileItem->setCheckState(Qt::Checked);
+//! [18]
}
}
-//! [19]
void MainWindow::useHighDpiPixmapsChanged(int checkState)
{
@@ -350,9 +343,7 @@ QWidget *MainWindow::createImagesGroupBox()
//! [21]
//! [22]
- QStringList labels;
-//! [22] //! [23]
- labels << tr("Image") << tr("Mode") << tr("State");
+ const QStringList labels({tr("Image"), tr("Mode"), tr("State")});
imagesTable->horizontalHeader()->setDefaultSectionSize(90);
imagesTable->setColumnCount(3);
@@ -361,18 +352,17 @@ QWidget *MainWindow::createImagesGroupBox()
imagesTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed);
imagesTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
imagesTable->verticalHeader()->hide();
-//! [23]
+//! [22]
//! [24]
connect(imagesTable, &QTableWidget::itemChanged,
-//! [24] //! [25]
this, &MainWindow::changeIcon);
QVBoxLayout *layout = new QVBoxLayout(imagesGroupBox);
layout->addWidget(imagesTable);
return imagesGroupBox;
+//! [24]
}
-//! [25]
//! [26]
QWidget *MainWindow::createIconSizeGroupBox()
@@ -428,8 +418,8 @@ QWidget *MainWindow::createIconSizeGroupBox()
layout->addLayout(otherSizeLayout, 3, 0, 1, 2);
layout->setRowStretch(4, 1);
return iconSizeGroupBox;
-}
//! [27]
+}
void MainWindow::screenChanged()
{
diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp
index 1ed55ca6cb..7de0c7c45b 100644
--- a/examples/widgets/widgets/imageviewer/imageviewer.cpp
+++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp
@@ -201,19 +201,20 @@ void ImageViewer::saveAs()
void ImageViewer::print()
//! [5] //! [6]
{
- Q_ASSERT(imageLabel->pixmap());
+ Q_ASSERT(!imageLabel->pixmap(Qt::ReturnByValue).isNull());
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
//! [6] //! [7]
QPrintDialog dialog(&printer, this);
//! [7] //! [8]
if (dialog.exec()) {
QPainter painter(&printer);
+ QPixmap pixmap = imageLabel->pixmap(Qt::ReturnByValue);
QRect rect = painter.viewport();
- QSize size = imageLabel->pixmap()->size();
+ QSize size = pixmap.size();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
- painter.setWindow(imageLabel->pixmap()->rect());
- painter.drawPixmap(0, 0, *imageLabel->pixmap());
+ painter.setWindow(pixmap.rect());
+ painter.drawPixmap(0, 0, pixmap);
}
#endif
}
@@ -384,9 +385,8 @@ void ImageViewer::updateActions()
void ImageViewer::scaleImage(double factor)
//! [23] //! [24]
{
- Q_ASSERT(imageLabel->pixmap());
scaleFactor *= factor;
- imageLabel->resize(scaleFactor * imageLabel->pixmap()->size());
+ imageLabel->resize(scaleFactor * imageLabel->pixmap(Qt::ReturnByValue).size());
adjustScrollBar(scrollArea->horizontalScrollBar(), factor);
adjustScrollBar(scrollArea->verticalScrollBar(), factor);
diff --git a/examples/widgets/widgets/scribble/main.cpp b/examples/widgets/widgets/scribble/main.cpp
index 1bf46b226f..cec6929827 100644
--- a/examples/widgets/widgets/scribble/main.cpp
+++ b/examples/widgets/widgets/scribble/main.cpp
@@ -54,6 +54,9 @@
int main(int argc, char *argv[])
{
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
MainWindow window;
window.show();
diff --git a/examples/widgets/widgets/sliders/main.cpp b/examples/widgets/widgets/sliders/main.cpp
index 99725195e5..9bf18cb6d4 100644
--- a/examples/widgets/widgets/sliders/main.cpp
+++ b/examples/widgets/widgets/sliders/main.cpp
@@ -54,6 +54,9 @@
int main(int argc, char *argv[])
{
+#ifdef Q_OS_ANDROID
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
QApplication app(argc, argv);
Window window;
window.show();
diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
index 31150cd994..34a63e0eea 100644
--- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
+++ b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
@@ -52,6 +52,7 @@
#include <QComboBox>
#include <QPainter>
+#include <QPainterPath>
#include <QPushButton>
#include <QStyleFactory>
diff --git a/examples/widgets/widgets/styles/widgetgallery.cpp b/examples/widgets/widgets/styles/widgetgallery.cpp
index d70c503f53..bf8e93feb4 100644
--- a/examples/widgets/widgets/styles/widgetgallery.cpp
+++ b/examples/widgets/widgets/styles/widgetgallery.cpp
@@ -75,8 +75,6 @@
WidgetGallery::WidgetGallery(QWidget *parent)
: QDialog(parent)
{
- originalPalette = QApplication::palette();
-
styleComboBox = new QComboBox;
const QString defaultStyleName = QApplication::style()->objectName();
QStringList styleNames = QStyleFactory::keys();
@@ -162,10 +160,8 @@ void WidgetGallery::changeStyle(const QString &styleName)
void WidgetGallery::changePalette()
//! [7] //! [8]
{
- if (useStylePaletteCheckBox->isChecked())
- QApplication::setPalette(QApplication::style()->standardPalette());
- else
- QApplication::setPalette(originalPalette);
+ QApplication::setPalette(useStylePaletteCheckBox->isChecked() ?
+ QApplication::style()->standardPalette() : QPalette());
}
//! [8]
diff --git a/examples/widgets/widgets/styles/widgetgallery.h b/examples/widgets/widgets/styles/widgetgallery.h
index 4deee6839a..8c4c880536 100644
--- a/examples/widgets/widgets/styles/widgetgallery.h
+++ b/examples/widgets/widgets/styles/widgetgallery.h
@@ -96,8 +96,6 @@ private:
void createBottomRightGroupBox();
void createProgressBar();
- QPalette originalPalette;
-
QLabel *styleLabel;
QComboBox *styleComboBox;
QCheckBox *useStylePaletteCheckBox;
diff --git a/examples/widgets/widgets/tablet/mainwindow.cpp b/examples/widgets/widgets/tablet/mainwindow.cpp
index 8bcb9ada63..c5b631ee44 100644
--- a/examples/widgets/widgets/tablet/mainwindow.cpp
+++ b/examples/widgets/widgets/tablet/mainwindow.cpp
@@ -85,21 +85,21 @@ void MainWindow::setBrushColor()
//! [2]
void MainWindow::setAlphaValuator(QAction *action)
{
- m_canvas->setAlphaChannelValuator(action->data().value<TabletCanvas::Valuator>());
+ m_canvas->setAlphaChannelValuator(qvariant_cast<TabletCanvas::Valuator>(action->data()));
}
//! [2]
//! [3]
void MainWindow::setLineWidthValuator(QAction *action)
{
- m_canvas->setLineWidthType(action->data().value<TabletCanvas::Valuator>());
+ m_canvas->setLineWidthType(qvariant_cast<TabletCanvas::Valuator>(action->data()));
}
//! [3]
//! [4]
void MainWindow::setSaturationValuator(QAction *action)
{
- m_canvas->setColorSaturationValuator(action->data().value<TabletCanvas::Valuator>());
+ m_canvas->setColorSaturationValuator(qvariant_cast<TabletCanvas::Valuator>(action->data()));
}
//! [4]
diff --git a/examples/widgets/widgets/tablet/tabletcanvas.cpp b/examples/widgets/widgets/tablet/tabletcanvas.cpp
index 59ca608cef..90a5017500 100644
--- a/examples/widgets/widgets/tablet/tabletcanvas.cpp
+++ b/examples/widgets/widgets/tablet/tabletcanvas.cpp
@@ -106,7 +106,7 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
break;
case QEvent::TabletMove:
#ifndef Q_OS_IOS
- if (event->device() == QTabletEvent::RotationStylus)
+ if (event->deviceType() == QTabletEvent::RotationStylus)
updateCursor(event);
#endif
if (m_deviceDown) {
@@ -161,7 +161,7 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
static qreal maxPenRadius = pressureToWidth(1.0);
painter.setRenderHint(QPainter::Antialiasing);
- switch (event->device()) {
+ switch (event->deviceType()) {
//! [6]
case QTabletEvent::Airbrush:
{
@@ -251,7 +251,7 @@ void TabletCanvas::updateBrush(const QTabletEvent *event)
m_color.setAlphaF(event->pressure());
break;
case TangentialPressureValuator:
- if (event->device() == QTabletEvent::Airbrush)
+ if (event->deviceType() == QTabletEvent::Airbrush)
m_color.setAlphaF(qMax(0.01, (event->tangentialPressure() + 1.0) / 2.0));
else
m_color.setAlpha(255);
@@ -312,7 +312,7 @@ void TabletCanvas::updateCursor(const QTabletEvent *event)
if (event->pointerType() == QTabletEvent::Eraser) {
cursor = QCursor(QPixmap(":/images/cursor-eraser.png"), 3, 28);
} else {
- switch (event->device()) {
+ switch (event->deviceType()) {
case QTabletEvent::Stylus:
cursor = QCursor(QPixmap(":/images/cursor-pencil.png"), 0, 0);
break;
diff --git a/examples/widgets/widgets/validators/localeselector.cpp b/examples/widgets/widgets/validators/localeselector.cpp
index 1382da0cc9..3dcd04d9ff 100644
--- a/examples/widgets/widgets/validators/localeselector.cpp
+++ b/examples/widgets/widgets/validators/localeselector.cpp
@@ -90,6 +90,6 @@ void LocaleSelector::emitLocaleSelected(int index)
QVariant v = itemData(index);
if (!v.isValid())
return;
- const QLocale l = v.value<QLocale>();
+ const QLocale l = qvariant_cast<QLocale>(v);
emit localeSelected(l);
}
diff --git a/examples/xml/dombookmarks/xbeltree.cpp b/examples/xml/dombookmarks/xbeltree.cpp
index d90cdc03b4..76ea5fb2bb 100644
--- a/examples/xml/dombookmarks/xbeltree.cpp
+++ b/examples/xml/dombookmarks/xbeltree.cpp
@@ -153,7 +153,7 @@ bool XbelTree::write(QIODevice *device) const
void XbelTree::updateDomElement(const QTreeWidgetItem *item, int column)
{
- QDomElement element = item->data(0, DomElementRole).value<QDomElement>();
+ QDomElement element = qvariant_cast<QDomElement>(item->data(0, DomElementRole));
if (!element.isNull()) {
if (column == 0) {
QDomElement oldTitleElement = element.firstChildElement(titleElement());
diff --git a/examples/xml/rsslisting/rsslisting.cpp b/examples/xml/rsslisting/rsslisting.cpp
index d1b4373531..143ad6dcba 100644
--- a/examples/xml/rsslisting/rsslisting.cpp
+++ b/examples/xml/rsslisting/rsslisting.cpp
@@ -131,7 +131,7 @@ void RSSListing::get(const QUrl &url)
currentReply = manager.get(request);
connect(currentReply, SIGNAL(readyRead()), this, SLOT(readyRead()));
connect(currentReply, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
- connect(currentReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError)));
+ connect(currentReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError)));
}
/*
diff --git a/examples/xml/saxbookmarks/doc/images/saxbookmarks-example.png b/examples/xml/saxbookmarks/doc/images/saxbookmarks-example.png
deleted file mode 100644
index 54d793be56..0000000000
--- a/examples/xml/saxbookmarks/doc/images/saxbookmarks-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/xml/saxbookmarks/jennifer.xbel b/examples/xml/saxbookmarks/jennifer.xbel
deleted file mode 100644
index 2501c118af..0000000000
--- a/examples/xml/saxbookmarks/jennifer.xbel
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE xbel>
-<xbel version="1.0">
- <folder folded="no">
- <title>Qt Resources</title>
- <bookmark href="http://qt.io/">
- <title>Qt home page</title>
- </bookmark>
- <bookmark href="https://www.qt.io/partners/">
- <title>Qt Partners</title>
- </bookmark>
- <bookmark href="https://www.qt.io/qt-training/">
- <title>Training</title>
- </bookmark>
- <bookmark href="http://doc.qt.io/">
- <title>Qt 5 documentation</title>
- </bookmark>
- <bookmark href="http://qt-project.org/faq/">
- <title>Frequently Asked Questions</title>
- </bookmark>
- <folder folded="yes">
- <title>Community Resources</title>
- <bookmark href="http://www.qtcentre.org/content/">
- <title>Qt Centre</title>
- </bookmark>
- <bookmark href="http://www.qtforum.org/">
- <title>QtForum.org</title>
- </bookmark>
- <bookmark href="http://digitalfanatics.org/projects/qt_tutorial/">
- <title>The Independent Qt Tutorial</title>
- </bookmark>
- <bookmark href="http://www.qtforum.de/">
- <title>German Qt Forum</title>
- </bookmark>
- <bookmark href="http://www.korone.net/">
- <title>Korean Qt Community Site</title>
- </bookmark>
- <bookmark href="http://prog.org.ru/">
- <title>Russian Qt Forum</title>
- </bookmark>
- </folder>
- </folder>
- <folder folded="no">
- <title>Online Dictionaries</title>
- <bookmark href="http://www.dictionary.com/">
- <title>Dictionary.com</title>
- </bookmark>
- <bookmark href="http://www.m-w.com/">
- <title>Merriam-Webster Online</title>
- </bookmark>
- <bookmark href="http://dictionary.cambridge.org/">
- <title>Cambridge Dictionaries Online</title>
- </bookmark>
- <bookmark href="http://www.onelook.com/">
- <title>OneLook Dictionary Search</title>
- </bookmark>
- <separator/>
- <bookmark href="http://dict.tu-chemnitz.de/">
- <title>TU Chemnitz German-English Dictionary</title>
- </bookmark>
- <separator/>
- <bookmark href="http://atilf.atilf.fr/tlf.htm">
- <title>Trésor de la Langue Française informatisé</title>
- </bookmark>
- <bookmark href="http://dictionnaires.atilf.fr/dictionnaires/ACADEMIE/">
- <title>Dictionnaire de l'Académie Française</title>
- </bookmark>
- </folder>
-</xbel>
diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp
deleted file mode 100644
index 8b7733081f..0000000000
--- a/examples/xml/saxbookmarks/mainwindow.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 <QtWidgets>
-
-#include "mainwindow.h"
-#include "xbelgenerator.h"
-#include "xbelhandler.h"
-
-MainWindow::MainWindow()
-{
- QStringList labels;
- labels << tr("Title") << tr("Location");
-
- treeWidget = new QTreeWidget;
- treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
- treeWidget->setHeaderLabels(labels);
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
- treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(treeWidget, &QWidget::customContextMenuRequested,
- this, &MainWindow::onCustomContextMenuRequested);
-#endif
- setCentralWidget(treeWidget);
-
- createMenus();
-
- statusBar()->showMessage(tr("Ready"));
-
- setWindowTitle(tr("SAX Bookmarks"));
- const QSize availableSize = screen()->availableGeometry().size();
- resize(availableSize.width() / 2, availableSize.height() / 3);
-}
-
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
-void MainWindow::onCustomContextMenuRequested(const QPoint &pos)
-{
- const QTreeWidgetItem *item = treeWidget->itemAt(pos);
- if (!item)
- return;
- const QString url = item->text(1);
- QMenu contextMenu;
- QAction *copyAction = contextMenu.addAction(tr("Copy Link to Clipboard"));
- QAction *openAction = contextMenu.addAction(tr("Open"));
- QAction *action = contextMenu.exec(treeWidget->viewport()->mapToGlobal(pos));
- if (action == copyAction)
- QGuiApplication::clipboard()->setText(url);
- else if (action == openAction)
- QDesktopServices::openUrl(QUrl(url));
-}
-#endif // !QT_NO_CONTEXTMENU && !QT_NO_CLIPBOARD
-
-void MainWindow::open()
-{
- QString fileName =
- QFileDialog::getOpenFileName(this, tr("Open Bookmark File"),
- QDir::currentPath(),
- tr("XBEL Files (*.xbel *.xml)"));
- if (fileName.isEmpty())
- return;
-
- treeWidget->clear();
-
- XbelHandler handler(treeWidget);
- QXmlSimpleReader reader;
- reader.setContentHandler(&handler);
- reader.setErrorHandler(&handler);
-
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("SAX Bookmarks"),
- tr("Cannot read file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName),
- file.errorString()));
- return;
- }
-
- QXmlInputSource xmlInputSource(&file);
- if (reader.parse(xmlInputSource))
- statusBar()->showMessage(tr("File loaded"), 2000);
-}
-
-void MainWindow::saveAs()
-{
- QString fileName =
- QFileDialog::getSaveFileName(this, tr("Save Bookmark File"),
- QDir::currentPath(),
- tr("XBEL Files (*.xbel *.xml)"));
- if (fileName.isEmpty())
- return;
-
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("SAX Bookmarks"),
- tr("Cannot write file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName),
- file.errorString()));
- return;
- }
-
- XbelGenerator generator(treeWidget);
- if (generator.write(&file))
- statusBar()->showMessage(tr("File saved"), 2000);
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About SAX Bookmarks"),
- tr("The <b>SAX Bookmarks</b> example demonstrates how to use Qt's "
- "SAX classes to read XML documents and how to generate XML by "
- "hand."));
-}
-
-void MainWindow::createMenus()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
- QAction *openAct = fileMenu->addAction(tr("&Open..."), this, &MainWindow::open);
- openAct->setShortcuts(QKeySequence::Open);
-
- QAction *saveAsAct = fileMenu->addAction(tr("&Save As..."), this, &MainWindow::saveAs);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
-
- QAction *exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close);
- exitAct->setShortcuts(QKeySequence::Quit);
-
- menuBar()->addSeparator();
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- helpMenu->addAction(tr("About &Qt"), qApp, &QCoreApplication::quit);
-}
diff --git a/examples/xml/saxbookmarks/saxbookmarks.pro b/examples/xml/saxbookmarks/saxbookmarks.pro
deleted file mode 100644
index af2a124a13..0000000000
--- a/examples/xml/saxbookmarks/saxbookmarks.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-HEADERS = mainwindow.h \
- xbelgenerator.h \
- xbelhandler.h
-SOURCES = main.cpp \
- mainwindow.cpp \
- xbelgenerator.cpp \
- xbelhandler.cpp
-QT += xml widgets
-requires(qtConfig(filedialog))
-
-EXAMPLE_FILES = frank.xbel jennifer.xbel
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/xml/saxbookmarks
-INSTALLS += target
diff --git a/examples/xml/saxbookmarks/xbelgenerator.cpp b/examples/xml/saxbookmarks/xbelgenerator.cpp
deleted file mode 100644
index 77cb6748fe..0000000000
--- a/examples/xml/saxbookmarks/xbelgenerator.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 <QtWidgets>
-
-#include "xbelgenerator.h"
-
-XbelGenerator::XbelGenerator(const QTreeWidget *treeWidget)
- : treeWidget(treeWidget)
-{
-}
-
-bool XbelGenerator::write(QIODevice *device)
-{
- out.setDevice(device);
- out.setCodec("UTF-8");
- out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<!DOCTYPE xbel>\n"
- << "<xbel version=\"1.0\">\n";
-
- for (int i = 0; i < treeWidget->topLevelItemCount(); ++i)
- generateItem(treeWidget->topLevelItem(i), 1);
-
- out << "</xbel>\n";
- return true;
-}
-
-QString XbelGenerator::indent(int depth)
-{
- const int IndentSize = 4;
- return QString(IndentSize * depth, ' ');
-}
-
-QString XbelGenerator::escapedText(const QString &str)
-{
- QString result = str;
- result.replace('&', "&amp;");
- result.replace('<', "&lt;");
- result.replace('>', "&gt;");
- return result;
-}
-
-QString XbelGenerator::escapedAttribute(const QString &str)
-{
- QString result = escapedText(str);
- result.replace(QLatin1Char('"'), "&quot;");
- result.prepend(QLatin1Char('"'));
- result.append(QLatin1Char('"'));
- return result;
-}
-
-void XbelGenerator::generateItem(const QTreeWidgetItem *item, int depth)
-{
- QString tagName = item->data(0, Qt::UserRole).toString();
- if (tagName == QLatin1String("folder")) {
- bool folded = !item->isExpanded();
- out << indent(depth) << "<folder folded=\"" << (folded ? "yes" : "no")
- << "\">\n"
- << indent(depth + 1) << "<title>" << escapedText(item->text(0))
- << "</title>\n";
-
- for (int i = 0; i < item->childCount(); ++i)
- generateItem(item->child(i), depth + 1);
-
- out << indent(depth) << "</folder>\n";
- } else if (tagName == QLatin1String("bookmark")) {
- out << indent(depth) << "<bookmark";
- if (!item->text(1).isEmpty())
- out << " href=" << escapedAttribute(item->text(1));
- out << ">\n"
- << indent(depth + 1) << "<title>" << escapedText(item->text(0))
- << "</title>\n"
- << indent(depth) << "</bookmark>\n";
- } else if (tagName == QLatin1String("separator")) {
- out << indent(depth) << "<separator/>\n";
- }
-}
diff --git a/examples/xml/saxbookmarks/xbelgenerator.h b/examples/xml/saxbookmarks/xbelgenerator.h
deleted file mode 100644
index abfabfd75c..0000000000
--- a/examples/xml/saxbookmarks/xbelgenerator.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-#ifndef XBELGENERATOR_H
-#define XBELGENERATOR_H
-
-#include <QTextStream>
-
-QT_BEGIN_NAMESPACE
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-class XbelGenerator
-{
-public:
- explicit XbelGenerator(const QTreeWidget *treeWidget);
-
- bool write(QIODevice *device);
-
-private:
- static QString indent(int indentLevel);
- static QString escapedText(const QString &str);
- static QString escapedAttribute(const QString &str);
- void generateItem(const QTreeWidgetItem *item, int depth);
-
- const QTreeWidget *treeWidget;
- QTextStream out;
-};
-
-#endif
diff --git a/examples/xml/saxbookmarks/xbelhandler.cpp b/examples/xml/saxbookmarks/xbelhandler.cpp
deleted file mode 100644
index 62dfbf9482..0000000000
--- a/examples/xml/saxbookmarks/xbelhandler.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 <QtWidgets>
-
-#include "xbelhandler.h"
-
-static inline QString versionAttribute() { return QStringLiteral("version"); }
-static inline QString hrefAttribute() { return QStringLiteral("href"); }
-static inline QString foldedAttribute() { return QStringLiteral("folded"); }
-
-XbelHandler::XbelHandler(QTreeWidget *treeWidget)
- : treeWidget(treeWidget)
-{
- item = 0;
- metXbelTag = false;
-
- QStyle *style = treeWidget->style();
-
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon),
- QIcon::Normal, QIcon::Off);
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon),
- QIcon::Normal, QIcon::On);
- bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
-}
-
-bool XbelHandler::startElement(const QString & /* namespaceURI */,
- const QString & /* localName */,
- const QString &qName,
- const QXmlAttributes &attributes)
-{
- if (!metXbelTag && qName != QLatin1String("xbel")) {
- errorStr = QObject::tr("The file is not an XBEL file.");
- return false;
- }
-
- if (qName == QLatin1String("xbel")) {
- QString version = attributes.value(versionAttribute());
- if (!version.isEmpty() && version != QLatin1String("1.0")) {
- errorStr = QObject::tr("The file is not an XBEL version 1.0 file.");
- return false;
- }
- metXbelTag = true;
- } else if (qName == QLatin1String("folder")) {
- item = createChildItem(qName);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- item->setIcon(0, folderIcon);
- item->setText(0, QObject::tr("Folder"));
- bool folded = (attributes.value(foldedAttribute()) != QLatin1String("no"));
- item->setExpanded(!folded);
- } else if (qName == QLatin1String("bookmark")) {
- item = createChildItem(qName);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- item->setIcon(0, bookmarkIcon);
- item->setText(0, QObject::tr("Unknown title"));
- item->setText(1, attributes.value(hrefAttribute()));
- } else if (qName == QLatin1String("separator")) {
- item = createChildItem(qName);
- item->setFlags(item->flags() & ~Qt::ItemIsSelectable);
- item->setText(0, QString(30, 0xB7));
- }
-
- currentText.clear();
- return true;
-}
-
-bool XbelHandler::endElement(const QString & /* namespaceURI */,
- const QString & /* localName */,
- const QString &qName)
-{
- if (qName == QLatin1String("title")) {
- if (item)
- item->setText(0, currentText);
- } else if (qName == QLatin1String("folder") || qName == QLatin1String("bookmark")
- || qName == QLatin1String("separator")) {
- item = item->parent();
- }
- return true;
-}
-
-bool XbelHandler::characters(const QString &str)
-{
- currentText += str;
- return true;
-}
-
-bool XbelHandler::fatalError(const QXmlParseException &exception)
-{
- QMessageBox::information(treeWidget->window(), QObject::tr("SAX Bookmarks"),
- QObject::tr("Parse error at line %1, column %2:\n"
- "%3")
- .arg(exception.lineNumber())
- .arg(exception.columnNumber())
- .arg(exception.message()));
- return false;
-}
-
-QString XbelHandler::errorString() const
-{
- return errorStr;
-}
-
-QTreeWidgetItem *XbelHandler::createChildItem(const QString &tagName)
-{
- QTreeWidgetItem *childItem;
- if (item) {
- childItem = new QTreeWidgetItem(item);
- } else {
- childItem = new QTreeWidgetItem(treeWidget);
- }
- childItem->setData(0, Qt::UserRole, tagName);
- return childItem;
-}
diff --git a/examples/xml/saxbookmarks/xbelhandler.h b/examples/xml/saxbookmarks/xbelhandler.h
deleted file mode 100644
index 3f4cb109e9..0000000000
--- a/examples/xml/saxbookmarks/xbelhandler.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-#ifndef XBELHANDLER_H
-#define XBELHANDLER_H
-
-#include <QIcon>
-#include <QXmlDefaultHandler>
-
-QT_BEGIN_NAMESPACE
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-class XbelHandler : public QXmlDefaultHandler
-{
-public:
- XbelHandler(QTreeWidget *treeWidget);
-
- bool startElement(const QString &namespaceURI, const QString &localName,
- const QString &qName, const QXmlAttributes &attributes) override;
- bool endElement(const QString &namespaceURI, const QString &localName,
- const QString &qName) override;
- bool characters(const QString &str) override;
- bool fatalError(const QXmlParseException &exception) override;
- QString errorString() const override;
-
-private:
- QTreeWidgetItem *createChildItem(const QString &tagName);
-
- QTreeWidget *treeWidget;
- QTreeWidgetItem *item;
- QString currentText;
- QString errorStr;
- bool metXbelTag;
-
- QIcon folderIcon;
- QIcon bookmarkIcon;
-};
-
-#endif
diff --git a/examples/xml/xml.pro b/examples/xml/xml.pro
index 72bf95b2ea..b0750574f4 100644
--- a/examples/xml/xml.pro
+++ b/examples/xml/xml.pro
@@ -4,7 +4,6 @@ SUBDIRS = htmlinfo \
qtHaveModule(widgets) {
SUBDIRS += dombookmarks \
- saxbookmarks \
streambookmarks
qtHaveModule(network): SUBDIRS += \