summaryrefslogtreecommitdiffstats
path: root/examples/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets')
-rw-r--r--examples/widgets/CMakeLists.txt4
-rw-r--r--examples/widgets/animation/CMakeLists.txt2
-rw-r--r--examples/widgets/desktop/CMakeLists.txt4
-rw-r--r--examples/widgets/dialogs/CMakeLists.txt14
-rw-r--r--examples/widgets/dialogs/standarddialogs/dialog.cpp8
-rw-r--r--examples/widgets/doc/images/regularexpression-example.pngbin78860 -> 75203 bytes
-rw-r--r--examples/widgets/doc/src/addressbook-tutorial.qdoc6
-rw-r--r--examples/widgets/doc/src/fetchmore.qdoc17
-rw-r--r--examples/widgets/draganddrop/CMakeLists.txt10
-rw-r--r--examples/widgets/effects/CMakeLists.txt4
-rw-r--r--examples/widgets/gestures/CMakeLists.txt2
-rw-r--r--examples/widgets/graphicsview/CMakeLists.txt22
-rw-r--r--examples/widgets/itemviews/CMakeLists.txt42
-rw-r--r--examples/widgets/itemviews/editabletreemodel/mainwindow.cpp2
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treemodel.cpp3
-rw-r--r--examples/widgets/itemviews/fetchmore/filelistmodel.cpp53
-rw-r--r--examples/widgets/itemviews/fetchmore/filelistmodel.h13
-rw-r--r--examples/widgets/itemviews/fetchmore/window.cpp48
-rw-r--r--examples/widgets/itemviews/fetchmore/window.h13
-rw-r--r--examples/widgets/layouts/CMakeLists.txt8
-rw-r--r--examples/widgets/mainwindows/CMakeLists.txt12
-rw-r--r--examples/widgets/mainwindows/mainwindow/toolbar.cpp2
-rw-r--r--examples/widgets/painting/CMakeLists.txt24
-rw-r--r--examples/widgets/painting/affine/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/affine/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/composition/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/composition/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/deform/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/deform/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/fontsampler/CMakeLists.txt1
-rw-r--r--examples/widgets/painting/gradients/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/gradients/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/gradients/gradients.cpp2
-rw-r--r--examples/widgets/painting/pathstroke/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/pathstroke/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/pathstroke/pathstroke.cpp24
-rw-r--r--examples/widgets/painting/shared/CMakeLists.txt8
-rw-r--r--examples/widgets/painting/shared/hoverpoints.cpp24
-rw-r--r--examples/widgets/painting/shared/use_lib.cmake13
-rw-r--r--examples/widgets/richtext/CMakeLists.txt8
-rw-r--r--examples/widgets/richtext/textedit/.prev_CMakeLists.txt2
-rw-r--r--examples/widgets/richtext/textedit/CMakeLists.txt2
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textundercolor.pngbin0 -> 6916 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textundercolor.pngbin0 -> 6916 bytes
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp160
-rw-r--r--examples/widgets/richtext/textedit/textedit.h8
-rw-r--r--examples/widgets/richtext/textedit/textedit.qrc2
-rw-r--r--examples/widgets/scroller/CMakeLists.txt2
-rw-r--r--examples/widgets/tools/CMakeLists.txt24
-rw-r--r--examples/widgets/tools/echoplugin/CMakeLists.txt4
-rw-r--r--examples/widgets/tools/plugandpaint/CMakeLists.txt16
-rw-r--r--examples/widgets/tools/plugandpaint/app/CMakeLists.txt56
-rw-r--r--examples/widgets/tools/plugandpaint/app/app.pro6
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt26
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt27
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.cpp114
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.h12
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.cpp2
-rw-r--r--examples/widgets/touch/CMakeLists.txt8
-rw-r--r--examples/widgets/touch/fingerpaint/scribblearea.cpp6
-rw-r--r--examples/widgets/touch/knobs/knob.cpp8
-rw-r--r--examples/widgets/touch/pinchzoom/graphicsview.cpp8
-rw-r--r--examples/widgets/tutorials/CMakeLists.txt2
-rw-r--r--examples/widgets/tutorials/addressbook/CMakeLists.txt14
-rw-r--r--examples/widgets/tutorials/gettingStarted/CMakeLists.txt3
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingstartedqt.qdoc7
-rw-r--r--examples/widgets/tutorials/modelview/CMakeLists.txt14
-rw-r--r--examples/widgets/tutorials/notepad/notepad.cpp68
-rw-r--r--examples/widgets/tutorials/notepad/notepad.h12
-rw-r--r--examples/widgets/tutorials/notepad/notepad.ui9
-rw-r--r--examples/widgets/tutorials/widgets/CMakeLists.txt8
-rw-r--r--examples/widgets/widgets/CMakeLists.txt50
-rw-r--r--examples/widgets/widgets/calendarwidget/window.cpp17
-rw-r--r--examples/widgets/widgets/imageviewer/imageviewer.cpp2
-rw-r--r--examples/widgets/widgets/stylesheet/mainwindow.cpp6
-rw-r--r--examples/widgets/widgets/validators/localeselector.cpp10
82 files changed, 949 insertions, 1979 deletions
diff --git a/examples/widgets/CMakeLists.txt b/examples/widgets/CMakeLists.txt
index 5026a40a80..753e3b8499 100644
--- a/examples/widgets/CMakeLists.txt
+++ b/examples/widgets/CMakeLists.txt
@@ -9,7 +9,7 @@ endif()
add_subdirectory(desktop)
add_subdirectory(dialogs)
add_subdirectory(effects)
-add_subdirectory(gallery)
+qt_internal_add_example(gallery)
add_subdirectory(gestures)
add_subdirectory(graphicsview)
add_subdirectory(itemviews)
@@ -28,5 +28,5 @@ if(QT_FEATURE_cursor) # special case
add_subdirectory(mainwindows)
endif()
if(QT_FEATURE_opengl AND TARGET Qt::Gui)
- add_subdirectory(windowcontainer)
+ qt_internal_add_example(windowcontainer)
endif()
diff --git a/examples/widgets/animation/CMakeLists.txt b/examples/widgets/animation/CMakeLists.txt
index e3382787aa..70f484a778 100644
--- a/examples/widgets/animation/CMakeLists.txt
+++ b/examples/widgets/animation/CMakeLists.txt
@@ -1,3 +1,3 @@
# Generated from animation.pro.
-add_subdirectory(easing)
+qt_internal_add_example(easing)
diff --git a/examples/widgets/desktop/CMakeLists.txt b/examples/widgets/desktop/CMakeLists.txt
index a50d3c2f0a..b317205c43 100644
--- a/examples/widgets/desktop/CMakeLists.txt
+++ b/examples/widgets/desktop/CMakeLists.txt
@@ -1,4 +1,4 @@
# Generated from desktop.pro.
-add_subdirectory(screenshot)
-add_subdirectory(systray)
+qt_internal_add_example(screenshot)
+qt_internal_add_example(systray)
diff --git a/examples/widgets/dialogs/CMakeLists.txt b/examples/widgets/dialogs/CMakeLists.txt
index 354424bf1f..32f8bc29a8 100644
--- a/examples/widgets/dialogs/CMakeLists.txt
+++ b/examples/widgets/dialogs/CMakeLists.txt
@@ -1,13 +1,13 @@
# Generated from dialogs.pro.
if(QT_FEATURE_wizard)
- add_subdirectory(classwizard)
- add_subdirectory(trivialwizard)
+ qt_internal_add_example(classwizard)
+ qt_internal_add_example(trivialwizard)
endif()
-add_subdirectory(extension)
-add_subdirectory(findfiles)
-add_subdirectory(standarddialogs)
-add_subdirectory(tabdialog)
+qt_internal_add_example(extension)
+qt_internal_add_example(findfiles)
+qt_internal_add_example(standarddialogs)
+qt_internal_add_example(tabdialog)
if(QT_FEATURE_wizard AND TARGET Qt::PrintSupport)
- add_subdirectory(licensewizard)
+ qt_internal_add_example(licensewizard)
endif()
diff --git a/examples/widgets/dialogs/standarddialogs/dialog.cpp b/examples/widgets/dialogs/standarddialogs/dialog.cpp
index cd7e8085a2..7df24e06f6 100644
--- a/examples/widgets/dialogs/standarddialogs/dialog.cpp
+++ b/examples/widgets/dialogs/standarddialogs/dialog.cpp
@@ -388,8 +388,14 @@ void Dialog::setColor()
void Dialog::setFont()
{
const QFontDialog::FontDialogOptions options = QFlag(fontDialogOptionsWidget->value());
+
+ const QString &description = fontLabel->text();
+ QFont defaultFont;
+ if (!description.isEmpty())
+ defaultFont.fromString(description);
+
bool ok;
- QFont font = QFontDialog::getFont(&ok, QFont(fontLabel->text()), this, "Select Font", options);
+ QFont font = QFontDialog::getFont(&ok, defaultFont, this, "Select Font", options);
if (ok) {
fontLabel->setText(font.key());
fontLabel->setFont(font);
diff --git a/examples/widgets/doc/images/regularexpression-example.png b/examples/widgets/doc/images/regularexpression-example.png
index d426d8514a..ac314a7748 100644
--- a/examples/widgets/doc/images/regularexpression-example.png
+++ b/examples/widgets/doc/images/regularexpression-example.png
Binary files differ
diff --git a/examples/widgets/doc/src/addressbook-tutorial.qdoc b/examples/widgets/doc/src/addressbook-tutorial.qdoc
index 563b6a2be9..53acb82b1a 100644
--- a/examples/widgets/doc/src/addressbook-tutorial.qdoc
+++ b/examples/widgets/doc/src/addressbook-tutorial.qdoc
@@ -842,7 +842,7 @@
If \c fileName is not empty, we create a QFile object, \c file, with
\c fileName. QFile works with QDataStream as QFile is a QIODevice.
- Next, we attempt to open the file in \l{QIODevice::}{WriteOnly} mode.
+ Next, we attempt to open the file in \l{QIODeviceBase::}{WriteOnly} mode.
If this is unsuccessful, we display a QMessageBox to inform the user.
\snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part2
@@ -869,7 +869,7 @@
\image addressbook-tutorial-part6-load.png
If \c fileName is not empty, again, we use a QFile object, \c file, and
- attempt to open it in \l{QIODevice::}{ReadOnly} mode. Similar to our
+ attempt to open it in \l{QIODeviceBase::}{ReadOnly} mode. Similar to our
implementation of \c saveToFile(), if this attempt is unsuccessful, we
display a QMessageBox to inform the user.
@@ -939,7 +939,7 @@
choose a location for the file. Using the file name chosen, we create an
instance of QFile to write to.
- We attempt to open the file in \l{QIODevice::}{WriteOnly} mode. If this
+ We attempt to open the file in \l{QIODeviceBase::}{WriteOnly} mode. If this
process fails, we display a QMessageBox to inform the user about the
problem and return. Otherwise, we pass the file as a parameter to a
QTextStream object, \c out. Like QDataStream, the QTextStream class
diff --git a/examples/widgets/doc/src/fetchmore.qdoc b/examples/widgets/doc/src/fetchmore.qdoc
index a27efaf071..940a252319 100644
--- a/examples/widgets/doc/src/fetchmore.qdoc
+++ b/examples/widgets/doc/src/fetchmore.qdoc
@@ -34,15 +34,9 @@
\image fetchmore-example.png
-
- This example consists of a dialog where you can enter a directory
- name in the \uicontrol Directory edit field. The application loads and
- visualizes all files it finds as you are typing. It is not required
- to press [Enter] to launch the search.
-
When you have large - or perhaps even infinite - data sets, you
will need to add items to the model in batches, and preferably only
- when the items are needed by the view (i.e., when they are visible
+ when the items are needed by the view (i.e., when they become visible
in the view).
In this example, we implement \c FileListModel - an item view
@@ -50,6 +44,15 @@
Window, which sets up the GUI and feeds the model with
directories.
+ The UI consists of a dialog with a list showing the contents
+ of the root directory. Directories can be navigated by double-clicking.
+
+ At the bottom, there is a log window displaying messages when the view
+ asks the model for more data.
+
+ To exercise it, navigate to a large directory (say \c /bin), and scroll
+ to the bottom. Log messages appear showing the data being retrieved.
+
Let's take a tour of \c {FileListModel}'s code.
\section1 FileListModel Class Definition
diff --git a/examples/widgets/draganddrop/CMakeLists.txt b/examples/widgets/draganddrop/CMakeLists.txt
index fbad523a73..87ba702aca 100644
--- a/examples/widgets/draganddrop/CMakeLists.txt
+++ b/examples/widgets/draganddrop/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from draganddrop.pro.
-add_subdirectory(draggableicons)
-add_subdirectory(draggabletext)
-add_subdirectory(dropsite)
-add_subdirectory(fridgemagnets)
-add_subdirectory(puzzle)
+qt_internal_add_example(draggableicons)
+qt_internal_add_example(draggabletext)
+qt_internal_add_example(dropsite)
+qt_internal_add_example(fridgemagnets)
+qt_internal_add_example(puzzle)
diff --git a/examples/widgets/effects/CMakeLists.txt b/examples/widgets/effects/CMakeLists.txt
index 6e8a892de1..1f62945f76 100644
--- a/examples/widgets/effects/CMakeLists.txt
+++ b/examples/widgets/effects/CMakeLists.txt
@@ -1,4 +1,4 @@
# Generated from effects.pro.
-add_subdirectory(blurpicker)
-add_subdirectory(fademessage)
+qt_internal_add_example(blurpicker)
+qt_internal_add_example(fademessage)
diff --git a/examples/widgets/gestures/CMakeLists.txt b/examples/widgets/gestures/CMakeLists.txt
index eb02ee41a9..34fb6d0202 100644
--- a/examples/widgets/gestures/CMakeLists.txt
+++ b/examples/widgets/gestures/CMakeLists.txt
@@ -3,4 +3,4 @@
if(NOT TARGET Qt::Widgets)
return()
endif()
-add_subdirectory(imagegestures)
+qt_internal_add_example(imagegestures)
diff --git a/examples/widgets/graphicsview/CMakeLists.txt b/examples/widgets/graphicsview/CMakeLists.txt
index a60ba190ef..961807eb55 100644
--- a/examples/widgets/graphicsview/CMakeLists.txt
+++ b/examples/widgets/graphicsview/CMakeLists.txt
@@ -1,15 +1,15 @@
# Generated from graphicsview.pro.
-add_subdirectory(chip)
-add_subdirectory(elasticnodes)
-add_subdirectory(embeddeddialogs)
-add_subdirectory(collidingmice)
-add_subdirectory(basicgraphicslayouts)
-add_subdirectory(diagramscene)
-add_subdirectory(flowlayout)
-add_subdirectory(anchorlayout)
-add_subdirectory(simpleanchorlayout)
-add_subdirectory(weatheranchorlayout)
+qt_internal_add_example(chip)
+qt_internal_add_example(elasticnodes)
+qt_internal_add_example(embeddeddialogs)
+qt_internal_add_example(collidingmice)
+qt_internal_add_example(basicgraphicslayouts)
+qt_internal_add_example(diagramscene)
+qt_internal_add_example(flowlayout)
+qt_internal_add_example(anchorlayout)
+qt_internal_add_example(simpleanchorlayout)
+qt_internal_add_example(weatheranchorlayout)
if(QT_FEATURE_cursor AND QT_FEATURE_draganddrop)
- add_subdirectory(dragdroprobot)
+ qt_internal_add_example(dragdroprobot)
endif()
diff --git a/examples/widgets/itemviews/CMakeLists.txt b/examples/widgets/itemviews/CMakeLists.txt
index 96f03a2e61..10d77c43c8 100644
--- a/examples/widgets/itemviews/CMakeLists.txt
+++ b/examples/widgets/itemviews/CMakeLists.txt
@@ -1,27 +1,27 @@
# Generated from itemviews.pro.
-add_subdirectory(addressbook)
-add_subdirectory(basicsortfiltermodel)
-add_subdirectory(chart)
-add_subdirectory(coloreditorfactory)
-add_subdirectory(combowidgetmapper)
-add_subdirectory(customsortfiltermodel)
-add_subdirectory(dirview)
-add_subdirectory(editabletreemodel)
-add_subdirectory(fetchmore)
-add_subdirectory(flattreeview)
-add_subdirectory(frozencolumn)
-add_subdirectory(interview)
-add_subdirectory(pixelator)
-add_subdirectory(simpletreemodel)
-add_subdirectory(simplewidgetmapper)
-add_subdirectory(spinboxdelegate)
-add_subdirectory(spreadsheet)
-add_subdirectory(stardelegate)
-add_subdirectory(storageview)
+qt_internal_add_example(addressbook)
+qt_internal_add_example(basicsortfiltermodel)
+qt_internal_add_example(chart)
+qt_internal_add_example(coloreditorfactory)
+qt_internal_add_example(combowidgetmapper)
+qt_internal_add_example(customsortfiltermodel)
+qt_internal_add_example(dirview)
+qt_internal_add_example(editabletreemodel)
+qt_internal_add_example(fetchmore)
+qt_internal_add_example(flattreeview)
+qt_internal_add_example(frozencolumn)
+qt_internal_add_example(interview)
+qt_internal_add_example(pixelator)
+qt_internal_add_example(simpletreemodel)
+qt_internal_add_example(simplewidgetmapper)
+qt_internal_add_example(spinboxdelegate)
+qt_internal_add_example(spreadsheet)
+qt_internal_add_example(stardelegate)
+qt_internal_add_example(storageview)
if(QT_FEATURE_draganddrop)
- add_subdirectory(puzzle)
+ qt_internal_add_example(puzzle)
endif()
if(TARGET Qt::Xml)
- add_subdirectory(simpledommodel)
+ qt_internal_add_example(simpledommodel)
endif()
diff --git a/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp b/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
index 7faa325469..47fc232751 100644
--- a/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
@@ -62,7 +62,7 @@ MainWindow::MainWindow(QWidget *parent)
QFile file(":/default.txt");
file.open(QIODevice::ReadOnly);
- TreeModel *model = new TreeModel(headers, file.readAll());
+ TreeModel *model = new TreeModel(headers, file.readAll(), this);
file.close();
view->setModel(model);
diff --git a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
index 1161a8b5d2..e8ca2afffd 100644
--- a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
@@ -212,6 +212,9 @@ bool TreeModel::removeRows(int position, int rows, const QModelIndex &parent)
//! [8]
int TreeModel::rowCount(const QModelIndex &parent) const
{
+ if (parent.isValid() && parent.column() > 0)
+ return 0;
+
const TreeItem *parentItem = getItem(parent);
return parentItem ? parentItem->childCount() : 0;
diff --git a/examples/widgets/itemviews/fetchmore/filelistmodel.cpp b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
index 3ee80617c0..5c93aba6f4 100644
--- a/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
+++ b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
@@ -54,8 +54,10 @@
#include <QDir>
#include <QPalette>
+static const int batchSize = 100;
+
FileListModel::FileListModel(QObject *parent)
- : QAbstractListModel(parent), fileCount(0)
+ : QAbstractListModel(parent)
{}
//![4]
@@ -67,24 +69,33 @@ int FileListModel::rowCount(const QModelIndex &parent) const
QVariant FileListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
- return QVariant();
-
- if (index.row() >= fileList.size() || index.row() < 0)
- return QVariant();
-
- if (role == Qt::DisplayRole) {
- return fileList.at(index.row());
- } else if (role == Qt::BackgroundRole) {
- int batch = (index.row() / 100) % 2;
- if (batch == 0)
- return qApp->palette().base();
- else
- return qApp->palette().alternateBase();
+ return {};
+
+ const int row = index.row();
+ if (row >= fileList.size() || row < 0)
+ return {};
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return fileList.at(row).fileName();
+ case Qt::BackgroundRole: {
+ const int batch = row / batchSize;
+ const QPalette &palette = QGuiApplication::palette();
+ return (batch % 2) != 0 ? palette.alternateBase() : palette.base();
+ }
+ case Qt::DecorationRole:
+ return iconProvider.icon(fileList.at(row));
}
- return QVariant();
+ return {};
}
+
//![4]
+QFileInfo FileListModel::fileInfoAt(const QModelIndex &index) const
+{
+ return fileList.at(index.row());
+}
+
//![1]
bool FileListModel::canFetchMore(const QModelIndex &parent) const
{
@@ -99,19 +110,20 @@ void FileListModel::fetchMore(const QModelIndex &parent)
{
if (parent.isValid())
return;
- int remainder = fileList.size() - fileCount;
- int itemsToFetch = qMin(100, remainder);
+ const int start = fileCount;
+ const int remainder = int(fileList.size()) - start;
+ const int itemsToFetch = qMin(batchSize, remainder);
if (itemsToFetch <= 0)
return;
- beginInsertRows(QModelIndex(), fileCount, fileCount + itemsToFetch - 1);
+ beginInsertRows(QModelIndex(), start, start + itemsToFetch - 1);
fileCount += itemsToFetch;
endInsertRows();
- emit numberPopulated(itemsToFetch);
+ emit numberPopulated(path, start, itemsToFetch, int(fileList.size()));
}
//![2]
@@ -121,7 +133,8 @@ void FileListModel::setDirPath(const QString &path)
QDir dir(path);
beginResetModel();
- fileList = dir.entryList();
+ this->path = path;
+ fileList = dir.entryInfoList(QDir::NoDot | QDir::AllEntries, QDir::Name);
fileCount = 0;
endResetModel();
}
diff --git a/examples/widgets/itemviews/fetchmore/filelistmodel.h b/examples/widgets/itemviews/fetchmore/filelistmodel.h
index 35cf6f7b46..1cd61f8c8e 100644
--- a/examples/widgets/itemviews/fetchmore/filelistmodel.h
+++ b/examples/widgets/itemviews/fetchmore/filelistmodel.h
@@ -52,7 +52,8 @@
#define FILELISTMODEL_H
#include <QAbstractListModel>
-#include <QStringList>
+#include <QFileInfoList>
+#include <QFileIconProvider>
//![0]
class FileListModel : public QAbstractListModel
@@ -65,8 +66,10 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QFileInfo fileInfoAt(const QModelIndex &) const;
+
signals:
- void numberPopulated(int number);
+ void numberPopulated(const QString &path, int start, int number, int total);
public slots:
void setDirPath(const QString &path);
@@ -76,8 +79,10 @@ protected:
void fetchMore(const QModelIndex &parent) override;
private:
- QStringList fileList;
- int fileCount;
+ QFileInfoList fileList;
+ QString path;
+ QFileIconProvider iconProvider;
+ int fileCount = 0;
};
//![0]
diff --git a/examples/widgets/itemviews/fetchmore/window.cpp b/examples/widgets/itemviews/fetchmore/window.cpp
index fa23bddc73..64746c18f8 100644
--- a/examples/widgets/itemviews/fetchmore/window.cpp
+++ b/examples/widgets/itemviews/fetchmore/window.cpp
@@ -56,37 +56,43 @@
Window::Window(QWidget *parent)
: QWidget(parent)
{
- FileListModel *model = new FileListModel(this);
- model->setDirPath(QLibraryInfo::path(QLibraryInfo::PrefixPath));
+ model = new FileListModel(this);
+ model->setDirPath(QDir::rootPath());
- QLabel *label = new QLabel(tr("&Directory:"));
- QLineEdit *lineEdit = new QLineEdit;
- label->setBuddy(lineEdit);
-
- QListView *view = new QListView;
+ view = new QListView;
view->setModel(model);
- logViewer = new QTextBrowser(this);
- logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
+ logViewer = new QPlainTextEdit(this);
+ logViewer->setReadOnly(true);
+ logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
+ QSizePolicy::Preferred));
- connect(lineEdit, &QLineEdit::textChanged,
- model, &FileListModel::setDirPath);
- connect(lineEdit, &QLineEdit::textChanged,
- logViewer, &QTextEdit::clear);
connect(model, &FileListModel::numberPopulated,
this, &Window::updateLog);
+ connect(view, &QAbstractItemView::activated,
+ this, &Window::activated);
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(label, 0, 0);
- layout->addWidget(lineEdit, 0, 1);
- layout->addWidget(view, 1, 0, 1, 2);
- layout->addWidget(logViewer, 2, 0, 1, 2);
+ auto *layout = new QVBoxLayout(this);
+ layout->addWidget(view);
+ layout->addWidget(logViewer);
- setLayout(layout);
setWindowTitle(tr("Fetch More Example"));
}
-void Window::updateLog(int number)
+void Window::updateLog(const QString &path, int start, int number, int total)
+{
+ const int last = start + number - 1;
+ const QString nativePath = QDir::toNativeSeparators(path);
+ const QString message = tr("%1..%2/%3 items from \"%4\" added.")
+ .arg(start).arg(last).arg(total).arg(nativePath);
+ logViewer->appendPlainText(message);
+}
+
+void Window::activated(const QModelIndex &index)
{
- logViewer->append(tr("%1 items added.").arg(number));
+ const QFileInfo fi = model->fileInfoAt(index);
+ if (fi.isDir()) {
+ logViewer->clear();
+ model->setDirPath(fi.absoluteFilePath());
+ }
}
diff --git a/examples/widgets/itemviews/fetchmore/window.h b/examples/widgets/itemviews/fetchmore/window.h
index 61bcb94bde..1f7c2a8728 100644
--- a/examples/widgets/itemviews/fetchmore/window.h
+++ b/examples/widgets/itemviews/fetchmore/window.h
@@ -54,9 +54,13 @@
#include <QWidget>
QT_BEGIN_NAMESPACE
-class QTextBrowser;
+class QModelIndex;
+class QListView;
+class QPlainTextEdit;
QT_END_NAMESPACE
+class FileListModel;
+
class Window : public QWidget
{
Q_OBJECT
@@ -65,10 +69,13 @@ public:
Window(QWidget *parent = nullptr);
public slots:
- void updateLog(int number);
+ void updateLog(const QString &path, int start, int number, int total);
+ void activated(const QModelIndex &);
private:
- QTextBrowser *logViewer;
+ QPlainTextEdit *logViewer;
+ FileListModel *model;
+ QListView *view;
};
#endif // WINDOW_H
diff --git a/examples/widgets/layouts/CMakeLists.txt b/examples/widgets/layouts/CMakeLists.txt
index eaca669248..656b602650 100644
--- a/examples/widgets/layouts/CMakeLists.txt
+++ b/examples/widgets/layouts/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from layouts.pro.
-add_subdirectory(basiclayouts)
-add_subdirectory(borderlayout)
-add_subdirectory(dynamiclayouts)
-add_subdirectory(flowlayout)
+qt_internal_add_example(basiclayouts)
+qt_internal_add_example(borderlayout)
+qt_internal_add_example(dynamiclayouts)
+qt_internal_add_example(flowlayout)
diff --git a/examples/widgets/mainwindows/CMakeLists.txt b/examples/widgets/mainwindows/CMakeLists.txt
index 8bb5f52f92..ba87029ef8 100644
--- a/examples/widgets/mainwindows/CMakeLists.txt
+++ b/examples/widgets/mainwindows/CMakeLists.txt
@@ -1,8 +1,8 @@
# Generated from mainwindows.pro.
-add_subdirectory(application)
-add_subdirectory(dockwidgets)
-add_subdirectory(mainwindow)
-add_subdirectory(mdi)
-add_subdirectory(menus)
-add_subdirectory(sdi)
+qt_internal_add_example(application)
+qt_internal_add_example(dockwidgets)
+qt_internal_add_example(mainwindow)
+qt_internal_add_example(mdi)
+qt_internal_add_example(menus)
+qt_internal_add_example(sdi)
diff --git a/examples/widgets/mainwindows/mainwindow/toolbar.cpp b/examples/widgets/mainwindows/mainwindow/toolbar.cpp
index 2c663a1618..431a804298 100644
--- a/examples/widgets/mainwindows/mainwindow/toolbar.cpp
+++ b/examples/widgets/mainwindows/mainwindow/toolbar.cpp
@@ -264,7 +264,7 @@ void ToolBar::randomize()
QList<QAction *> randomized;
QList<QAction *> actions = this->actions();
while (!actions.isEmpty()) {
- QAction *action = actions.takeAt(QRandomGenerator::global()->bounded(int(actions.size())));
+ QAction *action = actions.takeAt(QRandomGenerator::global()->bounded(actions.size()));
randomized.append(action);
}
clear();
diff --git a/examples/widgets/painting/CMakeLists.txt b/examples/widgets/painting/CMakeLists.txt
index 8a106982cf..40ebafdc31 100644
--- a/examples/widgets/painting/CMakeLists.txt
+++ b/examples/widgets/painting/CMakeLists.txt
@@ -1,14 +1,14 @@
# Generated from painting.pro.
-add_subdirectory(shared) # special case
-add_subdirectory(basicdrawing)
-add_subdirectory(concentriccircles)
-add_subdirectory(affine)
-# add_subdirectory(composition) # special case FIXME: Seems buggy wrt. usesOpenGL function
-add_subdirectory(deform)
-add_subdirectory(gradients)
-add_subdirectory(pathstroke)
-add_subdirectory(imagecomposition)
-add_subdirectory(painterpaths)
-add_subdirectory(transformations)
-add_subdirectory(fontsampler)
+#add_subdirectory(shared) # special case pulled in by other subdirs as needed
+qt_internal_add_example(basicdrawing)
+qt_internal_add_example(concentriccircles)
+qt_internal_add_example(affine)
+# qt_internal_add_example(composition) # special case FIXME: Seems buggy wrt. usesOpenGL function
+qt_internal_add_example(deform)
+qt_internal_add_example(gradients)
+qt_internal_add_example(pathstroke)
+qt_internal_add_example(imagecomposition)
+qt_internal_add_example(painterpaths)
+qt_internal_add_example(transformations)
+qt_internal_add_example(fontsampler)
diff --git a/examples/widgets/painting/affine/.prev_CMakeLists.txt b/examples/widgets/painting/affine/.prev_CMakeLists.txt
index d367ef75bd..4efe5f28a7 100644
--- a/examples/widgets/painting/affine/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/affine/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(affine PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(affine "shared"
diff --git a/examples/widgets/painting/affine/CMakeLists.txt b/examples/widgets/painting/affine/CMakeLists.txt
index c3323693b8..21f6c41028 100644
--- a/examples/widgets/painting/affine/CMakeLists.txt
+++ b/examples/widgets/painting/affine/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(affine PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(affine PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(affine "shared"
diff --git a/examples/widgets/painting/composition/.prev_CMakeLists.txt b/examples/widgets/painting/composition/.prev_CMakeLists.txt
index 5e3cb8c10c..7cf2aab45f 100644
--- a/examples/widgets/painting/composition/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/composition/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(composition PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(composition "shared"
diff --git a/examples/widgets/painting/composition/CMakeLists.txt b/examples/widgets/painting/composition/CMakeLists.txt
index 8192439737..0394e6a312 100644
--- a/examples/widgets/painting/composition/CMakeLists.txt
+++ b/examples/widgets/painting/composition/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(composition PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(composition PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(composition "shared"
diff --git a/examples/widgets/painting/deform/.prev_CMakeLists.txt b/examples/widgets/painting/deform/.prev_CMakeLists.txt
index 4462680de7..c99df00a5a 100644
--- a/examples/widgets/painting/deform/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/deform/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(deform PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(deform "shared"
diff --git a/examples/widgets/painting/deform/CMakeLists.txt b/examples/widgets/painting/deform/CMakeLists.txt
index c2517ac66f..6ab43cc371 100644
--- a/examples/widgets/painting/deform/CMakeLists.txt
+++ b/examples/widgets/painting/deform/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(deform PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(deform PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(deform "shared"
diff --git a/examples/widgets/painting/fontsampler/CMakeLists.txt b/examples/widgets/painting/fontsampler/CMakeLists.txt
index d3a7680bdc..76bae96edd 100644
--- a/examples/widgets/painting/fontsampler/CMakeLists.txt
+++ b/examples/widgets/painting/fontsampler/CMakeLists.txt
@@ -18,6 +18,7 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/fontsampler")
find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
+find_package(Qt6 COMPONENTS PrintSupport)
qt_add_executable(fontsampler
main.cpp
diff --git a/examples/widgets/painting/gradients/.prev_CMakeLists.txt b/examples/widgets/painting/gradients/.prev_CMakeLists.txt
index 7e798d032e..1260b18089 100644
--- a/examples/widgets/painting/gradients/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/gradients/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(gradients PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(gradients "shared"
diff --git a/examples/widgets/painting/gradients/CMakeLists.txt b/examples/widgets/painting/gradients/CMakeLists.txt
index 6ad4dfa771..bfc9ea888b 100644
--- a/examples/widgets/painting/gradients/CMakeLists.txt
+++ b/examples/widgets/painting/gradients/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(gradients PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(gradients PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(gradients "shared"
diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp
index 76d5818d32..045da2b0c0 100644
--- a/examples/widgets/painting/gradients/gradients.cpp
+++ b/examples/widgets/painting/gradients/gradients.cpp
@@ -105,6 +105,8 @@ uint ShadeWidget::colorAt(int x)
for (int i = 1; i < pts.size(); ++i) {
if (pts.at(i - 1).x() <= x && pts.at(i).x() >= x) {
QLineF l(pts.at(i - 1), pts.at(i));
+ if (qIsNull(l.dx()))
+ continue;
l.setLength(l.length() * ((x - l.x1()) / l.dx()));
return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))),
qRound(qMin(l.y2(), qreal(m_shade.height() - 1))));
diff --git a/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt b/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt
index 22a6635164..e2c1d5f793 100644
--- a/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(pathstroke PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(pathstroke "shared"
diff --git a/examples/widgets/painting/pathstroke/CMakeLists.txt b/examples/widgets/painting/pathstroke/CMakeLists.txt
index 17de61fede..54e61e1c32 100644
--- a/examples/widgets/painting/pathstroke/CMakeLists.txt
+++ b/examples/widgets/painting/pathstroke/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(pathstroke PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(pathstroke PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(pathstroke "shared"
diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp
index 412c2da6a4..bfa588f201 100644
--- a/examples/widgets/painting/pathstroke/pathstroke.cpp
+++ b/examples/widgets/painting/pathstroke/pathstroke.cpp
@@ -622,11 +622,11 @@ bool PathStrokeRenderer::event(QEvent *e)
case QEvent::TouchUpdate:
{
const QTouchEvent *const event = static_cast<const QTouchEvent*>(e);
- const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
- for (const QTouchEvent::TouchPoint &touchPoint : points) {
- const int id = touchPoint.id();
- switch (touchPoint.state()) {
- case Qt::TouchPointPressed:
+ const auto points = event->points();
+ for (const auto &point : points) {
+ const int id = point.id();
+ switch (point.state()) {
+ case QEventPoint::Pressed:
{
// find the point, move it
const auto mappedPoints = m_fingerPointMapping.values();
@@ -638,32 +638,32 @@ bool PathStrokeRenderer::event(QEvent *e)
if (activePoints.contains(i))
continue;
- qreal d = QLineF(touchPoint.position(), m_points.at(i)).length();
+ qreal d = QLineF(point.position(), m_points.at(i)).length();
if ((distance < 0 && d < 12 * m_pointSize) || d < distance) {
distance = d;
activePoint = i;
}
}
if (activePoint != -1) {
- m_fingerPointMapping.insert(touchPoint.id(), activePoint);
- m_points[activePoint] = touchPoint.position();
+ m_fingerPointMapping.insert(point.id(), activePoint);
+ m_points[activePoint] = point.position();
}
break;
}
- case Qt::TouchPointReleased:
+ case QEventPoint::Released:
{
// move the point and release
QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
- m_points[it.value()] = touchPoint.position();
+ m_points[it.value()] = point.position();
m_fingerPointMapping.erase(it);
break;
}
- case Qt::TouchPointMoved:
+ case QEventPoint::Updated:
{
// move the point
const int pointIdx = m_fingerPointMapping.value(id, -1);
if (pointIdx >= 0)
- m_points[pointIdx] = touchPoint.position();
+ m_points[pointIdx] = point.position();
break;
}
default:
diff --git a/examples/widgets/painting/shared/CMakeLists.txt b/examples/widgets/painting/shared/CMakeLists.txt
index 9d43e4a980..0fc65d3d99 100644
--- a/examples/widgets/painting/shared/CMakeLists.txt
+++ b/examples/widgets/painting/shared/CMakeLists.txt
@@ -1,14 +1,6 @@
# special case skip regeneration
# Port of shared.pri to be included by painting examples
-if(NOT TARGET Qt::Widgets)
- find_package(Qt6 REQUIRED COMPONENTS Widgets)
-endif()
-
-if(NOT TARGET Qt::OpenGL)
- find_package(Qt6 OPTIONAL_COMPONENTS OpenGL)
-endif()
-
add_library(painting_shared OBJECT)
add_library(painting_shared::painting_shared ALIAS painting_shared)
qt6_wrap_cpp(moc_files arthurwidgets.h hoverpoints.h) # no automoc for OBJECT libs:-/
diff --git a/examples/widgets/painting/shared/hoverpoints.cpp b/examples/widgets/painting/shared/hoverpoints.cpp
index 9fe947cedc..417d593d04 100644
--- a/examples/widgets/painting/shared/hoverpoints.cpp
+++ b/examples/widgets/painting/shared/hoverpoints.cpp
@@ -176,12 +176,12 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
case QEvent::TouchUpdate:
{
const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event);
- const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints();
+ const auto points = touchEvent->points();
const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height());
- for (const QTouchEvent::TouchPoint &touchPoint : points) {
- const int id = touchPoint.id();
- switch (touchPoint.state()) {
- case Qt::TouchPointPressed:
+ for (const auto &point : points) {
+ const int id = point.id();
+ switch (point.state()) {
+ case QEventPoint::Pressed:
{
// find the point, move it
const auto mappedPoints = m_fingerPointMapping.values();
@@ -197,7 +197,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
if (activePoints.contains(i))
continue;
- qreal d = QLineF(touchPoint.position(), m_points.at(i)).length();
+ qreal d = QLineF(point.position(), m_points.at(i)).length();
if ((distance < 0 && d < 12 * pointSize) || d < distance) {
distance = d;
activePoint = i;
@@ -206,25 +206,25 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
}
}
if (activePoint != -1) {
- m_fingerPointMapping.insert(touchPoint.id(), activePoint);
- movePoint(activePoint, touchPoint.position());
+ m_fingerPointMapping.insert(point.id(), activePoint);
+ movePoint(activePoint, point.position());
}
}
break;
- case Qt::TouchPointReleased:
+ case QEventPoint::Released:
{
// move the point and release
QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
- movePoint(it.value(), touchPoint.position());
+ movePoint(it.value(), point.position());
m_fingerPointMapping.erase(it);
}
break;
- case Qt::TouchPointMoved:
+ case QEventPoint::Updated:
{
// move the point
const int pointIdx = m_fingerPointMapping.value(id, -1);
if (pointIdx >= 0) // do we track this point?
- movePoint(pointIdx, touchPoint.position());
+ movePoint(pointIdx, point.position());
}
break;
default:
diff --git a/examples/widgets/painting/shared/use_lib.cmake b/examples/widgets/painting/shared/use_lib.cmake
new file mode 100644
index 0000000000..11e9c2cf71
--- /dev/null
+++ b/examples/widgets/painting/shared/use_lib.cmake
@@ -0,0 +1,13 @@
+# Include this file in your example project to use the library defined in this directory.
+# This avoids find_package calls in a directory scope different from the directory scope of the
+# consuming target.
+
+if(NOT TARGET Qt::Widgets)
+ find_package(Qt6 REQUIRED COMPONENTS Widgets)
+endif()
+
+if(NOT TARGET Qt::OpenGL)
+ find_package(Qt6 OPTIONAL_COMPONENTS OpenGL)
+endif()
+
+add_subdirectory("${CMAKE_CURRENT_LIST_DIR}" painting_shared)
diff --git a/examples/widgets/richtext/CMakeLists.txt b/examples/widgets/richtext/CMakeLists.txt
index adb98e38f9..86bbcccea5 100644
--- a/examples/widgets/richtext/CMakeLists.txt
+++ b/examples/widgets/richtext/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from richtext.pro.
-add_subdirectory(calendar)
-add_subdirectory(orderform)
-add_subdirectory(syntaxhighlighter)
-add_subdirectory(textedit)
+qt_internal_add_example(calendar)
+qt_internal_add_example(orderform)
+qt_internal_add_example(syntaxhighlighter)
+qt_internal_add_example(textedit)
diff --git a/examples/widgets/richtext/textedit/.prev_CMakeLists.txt b/examples/widgets/richtext/textedit/.prev_CMakeLists.txt
index 97fde062dd..c32496a98b 100644
--- a/examples/widgets/richtext/textedit/.prev_CMakeLists.txt
+++ b/examples/widgets/richtext/textedit/.prev_CMakeLists.txt
@@ -59,6 +59,7 @@ set(textedit_resource_files
"images/mac/textleft.png"
"images/mac/textright.png"
"images/mac/textunder.png"
+ "images/mac/textundercolor.png"
"images/mac/zoomin.png"
"images/mac/zoomout.png"
"images/win/checkbox-checked.png"
@@ -82,6 +83,7 @@ set(textedit_resource_files
"images/win/textleft.png"
"images/win/textright.png"
"images/win/textunder.png"
+ "images/win/textundercolor.png"
"images/win/zoomin.png"
"images/win/zoomout.png"
)
diff --git a/examples/widgets/richtext/textedit/CMakeLists.txt b/examples/widgets/richtext/textedit/CMakeLists.txt
index a376f9f747..8940fd5abf 100644
--- a/examples/widgets/richtext/textedit/CMakeLists.txt
+++ b/examples/widgets/richtext/textedit/CMakeLists.txt
@@ -65,6 +65,7 @@ set(textedit_resource_files
"images/mac/textleft.png"
"images/mac/textright.png"
"images/mac/textunder.png"
+ "images/mac/textundercolor.png"
"images/mac/zoomin.png"
"images/mac/zoomout.png"
"images/win/checkbox-checked.png"
@@ -88,6 +89,7 @@ set(textedit_resource_files
"images/win/textleft.png"
"images/win/textright.png"
"images/win/textunder.png"
+ "images/win/textundercolor.png"
"images/win/zoomin.png"
"images/win/zoomout.png"
)
diff --git a/examples/widgets/richtext/textedit/images/mac/textundercolor.png b/examples/widgets/richtext/textedit/images/mac/textundercolor.png
new file mode 100644
index 0000000000..30e24e61c3
--- /dev/null
+++ b/examples/widgets/richtext/textedit/images/mac/textundercolor.png
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textundercolor.png b/examples/widgets/richtext/textedit/images/win/textundercolor.png
new file mode 100644
index 0000000000..30e24e61c3
--- /dev/null
+++ b/examples/widgets/richtext/textedit/images/win/textundercolor.png
Binary files differ
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
index 194e1e3d92..66a3370811 100644
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ b/examples/widgets/richtext/textedit/textedit.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the demonstration applications of the Qt Toolkit.
@@ -48,6 +48,8 @@
**
****************************************************************************/
+#include "textedit.h"
+
#include <QActionGroup>
#include <QApplication>
#include <QClipboard>
@@ -84,8 +86,6 @@
#endif
#endif
-#include "textedit.h"
-
#ifdef Q_OS_MAC
const QString rsrcPath = ":/images/mac";
#else
@@ -125,19 +125,20 @@ TextEdit::TextEdit(QWidget *parent)
colorChanged(textEdit->textColor());
alignmentChanged(textEdit->alignment());
- connect(textEdit->document(), &QTextDocument::modificationChanged,
+ auto *document = textEdit->document();
+ connect(document, &QTextDocument::modificationChanged,
actionSave, &QAction::setEnabled);
- connect(textEdit->document(), &QTextDocument::modificationChanged,
+ connect(document, &QTextDocument::modificationChanged,
this, &QWidget::setWindowModified);
- connect(textEdit->document(), &QTextDocument::undoAvailable,
+ connect(document, &QTextDocument::undoAvailable,
actionUndo, &QAction::setEnabled);
- connect(textEdit->document(), &QTextDocument::redoAvailable,
+ connect(document, &QTextDocument::redoAvailable,
actionRedo, &QAction::setEnabled);
- setWindowModified(textEdit->document()->isModified());
- actionSave->setEnabled(textEdit->document()->isModified());
- actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
- actionRedo->setEnabled(textEdit->document()->isRedoAvailable());
+ setWindowModified(document->isModified());
+ actionSave->setEnabled(document->isModified());
+ actionUndo->setEnabled(document->isUndoAvailable());
+ actionRedo->setEnabled(document->isRedoAvailable());
#ifndef QT_NO_CLIPBOARD
actionCut->setEnabled(false);
@@ -145,7 +146,8 @@ TextEdit::TextEdit(QWidget *parent)
actionCopy->setEnabled(false);
connect(textEdit, &QTextEdit::copyAvailable, actionCopy, &QAction::setEnabled);
- connect(QApplication::clipboard(), &QClipboard::dataChanged, this, &TextEdit::clipboardDataChanged);
+ connect(QGuiApplication::clipboard(), &QClipboard::dataChanged,
+ this, &TextEdit::clipboardDataChanged);
#endif
textEdit->setFocus();
@@ -254,7 +256,7 @@ void TextEdit::setupEditActions()
actionPaste->setPriority(QAction::LowPriority);
actionPaste->setShortcut(QKeySequence::Paste);
tb->addAction(actionPaste);
- if (const QMimeData *md = QApplication::clipboard()->mimeData())
+ if (const QMimeData *md = QGuiApplication::clipboard()->mimeData())
actionPaste->setEnabled(md->hasText());
#endif
}
@@ -325,11 +327,11 @@ void TextEdit::setupTextActions()
actionIndentLess->setShortcut(Qt::CTRL | Qt::Key_BracketLeft);
actionIndentLess->setPriority(QAction::LowPriority);
- // Make sure the alignLeft is always left of the alignRight
+ // Make sure the alignLeft is always left of the alignRight
QActionGroup *alignGroup = new QActionGroup(this);
connect(alignGroup, &QActionGroup::triggered, this, &TextEdit::textAlign);
- if (QApplication::isLeftToRight()) {
+ if (QGuiApplication::isLeftToRight()) {
alignGroup->addAction(actionAlignLeft);
alignGroup->addAction(actionAlignCenter);
alignGroup->addAction(actionAlignRight);
@@ -354,6 +356,10 @@ void TextEdit::setupTextActions()
actionTextColor = menu->addAction(pix, tr("&Color..."), this, &TextEdit::textColor);
tb->addAction(actionTextColor);
+ const QIcon underlineColorIcon(rsrcPath + "/textundercolor.png");
+ actionUnderlineColor = menu->addAction(underlineColorIcon, tr("Underline color..."), this, &TextEdit::underlineColor);
+ tb->addAction(actionUnderlineColor);
+
menu->addSeparator();
const QIcon checkboxIcon = QIcon::fromTheme("status-checkbox-checked", QIcon(rsrcPath + "/checkbox-checked.png"));
@@ -370,23 +376,23 @@ void TextEdit::setupTextActions()
comboStyle = new QComboBox(tb);
tb->addWidget(comboStyle);
- comboStyle->addItem("Standard");
- comboStyle->addItem("Bullet List (Disc)");
- comboStyle->addItem("Bullet List (Circle)");
- comboStyle->addItem("Bullet List (Square)");
- comboStyle->addItem("Task List (Unchecked)");
- comboStyle->addItem("Task List (Checked)");
- comboStyle->addItem("Ordered List (Decimal)");
- comboStyle->addItem("Ordered List (Alpha lower)");
- comboStyle->addItem("Ordered List (Alpha upper)");
- comboStyle->addItem("Ordered List (Roman lower)");
- comboStyle->addItem("Ordered List (Roman upper)");
- comboStyle->addItem("Heading 1");
- comboStyle->addItem("Heading 2");
- comboStyle->addItem("Heading 3");
- comboStyle->addItem("Heading 4");
- comboStyle->addItem("Heading 5");
- comboStyle->addItem("Heading 6");
+ comboStyle->addItems({"Standard",
+ "Bullet List (Disc)",
+ "Bullet List (Circle)",
+ "Bullet List (Square)",
+ "Task List (Unchecked)",
+ "Task List (Checked)",
+ "Ordered List (Decimal)",
+ "Ordered List (Alpha lower)",
+ "Ordered List (Alpha upper)",
+ "Ordered List (Roman lower)",
+ "Ordered List (Roman upper)",
+ "Heading 1",
+ "Heading 2",
+ "Heading 3",
+ "Heading 4",
+ "Heading 5",
+ "Heading 6"}),
connect(comboStyle, &QComboBox::activated, this, &TextEdit::textStyle);
@@ -417,14 +423,15 @@ bool TextEdit::load(const QString &f)
QByteArray data = file.readAll();
QMimeDatabase db;
- if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("text/html")) {
+ const QString &mimeTypeName = db.mimeTypeForFileNameAndData(f, data).name();
+ if (mimeTypeName == u"text/html") {
auto encoding = QStringDecoder::encodingForHtml(data);
QString str = QStringDecoder(encoding ? *encoding : QStringDecoder::Utf8)(data);
- QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename);
- textEdit->document()->setBaseUrl(baseUrl);
+ QUrl fileUrl = f.startsWith(u':') ? QUrl(f) : QUrl::fromLocalFile(f);
+ textEdit->document()->setBaseUrl(fileUrl.adjusted(QUrl::RemoveFilename));
textEdit->setHtml(str);
#if QT_CONFIG(textmarkdownreader)
- } else if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("text/markdown")) {
+ } else if (mimeTypeName == u"text/markdown") {
textEdit->setMarkdown(QString::fromUtf8(data));
#endif
} else {
@@ -447,7 +454,7 @@ bool TextEdit::maybeSave()
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
if (ret == QMessageBox::Save)
return fileSave();
- else if (ret == QMessageBox::Cancel)
+ if (ret == QMessageBox::Cancel)
return false;
return true;
}
@@ -471,7 +478,7 @@ void TextEdit::fileNew()
{
if (maybeSave()) {
textEdit->clear();
- setCurrentFileName(QString());
+ setCurrentFileName({});
}
}
@@ -480,18 +487,18 @@ void TextEdit::fileOpen()
QFileDialog fileDialog(this, tr("Open File..."));
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setFileMode(QFileDialog::ExistingFile);
- fileDialog.setMimeTypeFilters(QStringList()
+ fileDialog.setMimeTypeFilters({
#if QT_CONFIG(texthtmlparser)
- << "text/html"
+ "text/html",
#endif
#if QT_CONFIG(textmarkdownreader)
- << "text/markdown"
+ "text/markdown",
#endif
- << "text/plain");
+ "text/plain"});
if (fileDialog.exec() != QDialog::Accepted)
return;
- const QString fn = fileDialog.selectedFiles().first();
+ const QString fn = fileDialog.selectedFiles().constFirst();
if (load(fn))
statusBar()->showMessage(tr("Opened \"%1\"").arg(QDir::toNativeSeparators(fn)));
else
@@ -500,9 +507,7 @@ void TextEdit::fileOpen()
bool TextEdit::fileSave()
{
- if (fileName.isEmpty())
- return fileSaveAs();
- if (fileName.startsWith(QStringLiteral(":/")))
+ if (fileName.isEmpty() || fileName.startsWith(u":/"))
return fileSaveAs();
QTextDocumentWriter writer(fileName);
@@ -521,22 +526,21 @@ bool TextEdit::fileSaveAs()
{
QFileDialog fileDialog(this, tr("Save as..."));
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
- QStringList mimeTypes;
- mimeTypes << "text/plain"
+ QStringList mimeTypes{"text/plain",
#if QT_CONFIG(textodfwriter)
- << "application/vnd.oasis.opendocument.text"
+ "application/vnd.oasis.opendocument.text",
#endif
#if QT_CONFIG(textmarkdownwriter)
- << "text/markdown"
+ "text/markdown",
#endif
- << "text/html";
+ "text/html"};
fileDialog.setMimeTypeFilters(mimeTypes);
#if QT_CONFIG(textodfwriter)
fileDialog.setDefaultSuffix("odt");
#endif
if (fileDialog.exec() != QDialog::Accepted)
return false;
- const QString fn = fileDialog.selectedFiles().first();
+ const QString fn = fileDialog.selectedFiles().constFirst();
setCurrentFileName(fn);
return fileSave();
}
@@ -545,13 +549,12 @@ void TextEdit::filePrint()
{
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QPrinter printer(QPrinter::HighResolution);
- QPrintDialog *dlg = new QPrintDialog(&printer, this);
+ QPrintDialog dlg(&printer, this);
if (textEdit->textCursor().hasSelection())
- dlg->setOption(QAbstractPrintDialog::PrintSelection);
- dlg->setWindowTitle(tr("Print Document"));
- if (dlg->exec() == QDialog::Accepted)
+ dlg.setOption(QAbstractPrintDialog::PrintSelection);
+ dlg.setWindowTitle(tr("Print Document"));
+ if (dlg.exec() == QDialog::Accepted)
textEdit->print(&printer);
- delete dlg;
#endif
}
@@ -560,21 +563,11 @@ void TextEdit::filePrintPreview()
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog)
QPrinter printer(QPrinter::HighResolution);
QPrintPreviewDialog preview(&printer, this);
- connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TextEdit::printPreview);
+ connect(&preview, &QPrintPreviewDialog::paintRequested, textEdit, &QTextEdit::print);
preview.exec();
#endif
}
-void TextEdit::printPreview(QPrinter *printer)
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
- textEdit->print(printer);
-#else
- Q_UNUSED(printer);
-#endif
-}
-
-
void TextEdit::filePrintPdf()
{
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
@@ -585,13 +578,13 @@ void TextEdit::filePrintPdf()
fileDialog.setDefaultSuffix("pdf");
if (fileDialog.exec() != QDialog::Accepted)
return;
- QString fileName = fileDialog.selectedFiles().first();
+ QString pdfFileName = fileDialog.selectedFiles().constFirst();
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
- printer.setOutputFileName(fileName);
+ printer.setOutputFileName(pdfFileName);
textEdit->document()->print(&printer);
statusBar()->showMessage(tr("Exported \"%1\"")
- .arg(QDir::toNativeSeparators(fileName)));
+ .arg(QDir::toNativeSeparators(pdfFileName)));
//! [0]
#endif
}
@@ -620,14 +613,14 @@ void TextEdit::textItalic()
void TextEdit::textFamily(const QString &f)
{
QTextCharFormat fmt;
- fmt.setFontFamily(f);
+ fmt.setFontFamilies({f});
mergeFormatOnWordOrSelection(fmt);
}
void TextEdit::textSize(const QString &p)
{
qreal pointSize = p.toFloat();
- if (p.toFloat() > 0) {
+ if (pointSize > 0) {
QTextCharFormat fmt;
fmt.setFontPointSize(pointSize);
mergeFormatOnWordOrSelection(fmt);
@@ -729,6 +722,17 @@ void TextEdit::textColor()
colorChanged(col);
}
+void TextEdit::underlineColor()
+{
+ QColor col = QColorDialog::getColor(Qt::black, this);
+ if (!col.isValid())
+ return;
+ QTextCharFormat fmt;
+ fmt.setUnderlineColor(col);
+ mergeFormatOnWordOrSelection(fmt);
+ colorChanged(col);
+}
+
void TextEdit::textAlign(QAction *a)
{
if (a == actionAlignLeft)
@@ -842,7 +846,7 @@ void TextEdit::cursorPositionChanged()
void TextEdit::clipboardDataChanged()
{
#ifndef QT_NO_CLIPBOARD
- if (const QMimeData *md = QApplication::clipboard()->mimeData())
+ if (const QMimeData *md = QGuiApplication::clipboard()->mimeData())
actionPaste->setEnabled(md->hasText());
#endif
}
@@ -881,13 +885,13 @@ void TextEdit::colorChanged(const QColor &c)
void TextEdit::alignmentChanged(Qt::Alignment a)
{
- if (a & Qt::AlignLeft)
+ if (a.testFlag(Qt::AlignLeft))
actionAlignLeft->setChecked(true);
- else if (a & Qt::AlignHCenter)
+ else if (a.testFlag(Qt::AlignHCenter))
actionAlignCenter->setChecked(true);
- else if (a & Qt::AlignRight)
+ else if (a.testFlag(Qt::AlignRight))
actionAlignRight->setChecked(true);
- else if (a & Qt::AlignJustify)
+ else if (a.testFlag(Qt::AlignJustify))
actionAlignJustify->setChecked(true);
}
diff --git a/examples/widgets/richtext/textedit/textedit.h b/examples/widgets/richtext/textedit/textedit.h
index 07a307f83d..6b95891d31 100644
--- a/examples/widgets/richtext/textedit/textedit.h
+++ b/examples/widgets/richtext/textedit/textedit.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the demonstration applications of the Qt Toolkit.
@@ -52,8 +52,6 @@
#define TEXTEDIT_H
#include <QMainWindow>
-#include <QMap>
-#include <QPointer>
QT_BEGIN_NAMESPACE
class QAction;
@@ -95,6 +93,7 @@ private slots:
void textSize(const QString &p);
void textStyle(int styleIndex);
void textColor();
+ void underlineColor();
void textAlign(QAction *a);
void setChecked(bool checked);
void indent();
@@ -105,7 +104,6 @@ private slots:
void clipboardDataChanged();
void about();
- void printPreview(QPrinter *);
private:
void setupFileActions();
@@ -125,6 +123,7 @@ private:
QAction *actionTextUnderline;
QAction *actionTextItalic;
QAction *actionTextColor;
+ QAction *actionUnderlineColor;
QAction *actionAlignLeft;
QAction *actionAlignCenter;
QAction *actionAlignRight;
@@ -144,7 +143,6 @@ private:
QFontComboBox *comboFont;
QComboBox *comboSize;
- QToolBar *tb;
QString fileName;
QTextEdit *textEdit;
};
diff --git a/examples/widgets/richtext/textedit/textedit.qrc b/examples/widgets/richtext/textedit/textedit.qrc
index 1641acc207..a30d50fdbf 100644
--- a/examples/widgets/richtext/textedit/textedit.qrc
+++ b/examples/widgets/richtext/textedit/textedit.qrc
@@ -22,6 +22,7 @@
<file>images/mac/textleft.png</file>
<file>images/mac/textright.png</file>
<file>images/mac/textunder.png</file>
+ <file>images/mac/textundercolor.png</file>
<file>images/mac/zoomin.png</file>
<file>images/mac/zoomout.png</file>
<file>images/win/checkbox.png</file>
@@ -45,6 +46,7 @@
<file>images/win/textleft.png</file>
<file>images/win/textright.png</file>
<file>images/win/textunder.png</file>
+ <file>images/win/textundercolor.png</file>
<file>images/win/zoomin.png</file>
<file>images/win/zoomout.png</file>
<file>example.html</file>
diff --git a/examples/widgets/scroller/CMakeLists.txt b/examples/widgets/scroller/CMakeLists.txt
index f663cd9890..37ee7ea08f 100644
--- a/examples/widgets/scroller/CMakeLists.txt
+++ b/examples/widgets/scroller/CMakeLists.txt
@@ -1,3 +1,3 @@
# Generated from scroller.pro.
-add_subdirectory(graphicsview)
+qt_internal_add_example(graphicsview)
diff --git a/examples/widgets/tools/CMakeLists.txt b/examples/widgets/tools/CMakeLists.txt
index 022f4a2b8f..0056518f1e 100644
--- a/examples/widgets/tools/CMakeLists.txt
+++ b/examples/widgets/tools/CMakeLists.txt
@@ -1,18 +1,22 @@
# Generated from tools.pro.
-add_subdirectory(completer)
-add_subdirectory(customcompleter)
+qt_internal_add_example(completer)
+qt_internal_add_example(customcompleter)
if(QT_FEATURE_translation) # special case
- add_subdirectory(i18n)
+ qt_internal_add_example(i18n)
endif()
-add_subdirectory(regularexpression)
-add_subdirectory(settingseditor)
-add_subdirectory(styleplugin)
-add_subdirectory(treemodelcompleter)
-add_subdirectory(undo)
-add_subdirectory(undoframework)
+qt_internal_add_example(regularexpression)
+qt_internal_add_example(settingseditor)
+qt_internal_add_example(styleplugin)
+qt_internal_add_example(treemodelcompleter)
+qt_internal_add_example(undo)
+qt_internal_add_example(undoframework)
if(QT_FEATURE_library) # special case
add_subdirectory(echoplugin)
- add_subdirectory(plugandpaint) # special case
+ # special case begin
+ if(QT_FEATURE_inputdialog)
+ qt_internal_add_example(plugandpaint)
+ endif()
+ # special case end
endif()
diff --git a/examples/widgets/tools/echoplugin/CMakeLists.txt b/examples/widgets/tools/echoplugin/CMakeLists.txt
index b848e08e72..380cfcae8e 100644
--- a/examples/widgets/tools/echoplugin/CMakeLists.txt
+++ b/examples/widgets/tools/echoplugin/CMakeLists.txt
@@ -1,4 +1,4 @@
# Generated from echoplugin.pro.
-add_subdirectory(echowindow)
-add_subdirectory(plugin)
+qt_internal_add_example(echowindow)
+qt_internal_add_example(plugin)
diff --git a/examples/widgets/tools/plugandpaint/CMakeLists.txt b/examples/widgets/tools/plugandpaint/CMakeLists.txt
index 4e35d0d0c3..3c997faf21 100644
--- a/examples/widgets/tools/plugandpaint/CMakeLists.txt
+++ b/examples/widgets/tools/plugandpaint/CMakeLists.txt
@@ -1,7 +1,19 @@
# Generated from plugandpaint.pro.
+# special case skip regeneration
+cmake_minimum_required(VERSION 3.14)
+project(plugandpaint LANGUAGES CXX)
-if(NOT QT_FEATURE_inputdialog)
- return()
+find_package(Qt6 COMPONENTS Core Gui Widgets)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint")
+
add_subdirectory(plugins)
add_subdirectory(app)
diff --git a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt b/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
index bdf934fa2c..14cdaeb822 100644
--- a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
+++ b/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
@@ -1,23 +1,5 @@
# Generated from app.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(plugandpaint LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+# special case skip regeneration
qt_add_executable(plugandpaint
interfaces.h
@@ -31,43 +13,9 @@ set_target_properties(plugandpaint PROPERTIES
MACOSX_BUNDLE TRUE
)
target_link_libraries(plugandpaint PUBLIC
- # Remove: L../plugins
- Qt::Core
- Qt::Gui
Qt::Widgets
- pnp_basictools # special case
+ pnp_basictools
)
-target_link_libraries(plugandpaint PUBLIC pnp_basictools) # special case
-
-if(macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- (
- )
- pnp_basictools$
- )
-endif()
-
-if(NOT macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- pnp_basictools
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (APPLE))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- _debug
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (WIN32))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- d
- )
-endif()
install(TARGETS plugandpaint
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tools/plugandpaint/app/app.pro b/examples/widgets/tools/plugandpaint/app/app.pro
index 558d359e7d..e5ff02ecf2 100644
--- a/examples/widgets/tools/plugandpaint/app/app.pro
+++ b/examples/widgets/tools/plugandpaint/app/app.pro
@@ -18,7 +18,11 @@ LIBS = -L../plugins
macx-xcode {
LIBS += -lpnp_basictools$($${QMAKE_XCODE_LIBRARY_SUFFIX_SETTING})
} else {
- LIBS += -lpnp_basictools
+ android {
+ LIBS += -lpnp_basictools_$${QT_ARCH}
+ } else {
+ LIBS += -lpnp_basictools
+ }
if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
mac:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)_debug
win32:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)d
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
index 97e4021d61..c66f83ce62 100644
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
+++ b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
@@ -1,23 +1,5 @@
# Generated from basictools.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_basictools LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+# special case skip regeneration
qt_add_plugin(pnp_basictools STATIC)
target_sources(pnp_basictools PRIVATE
@@ -36,9 +18,3 @@ target_link_libraries(pnp_basictools PUBLIC
Qt::Gui
Qt::Widgets
)
-
-install(TARGETS pnp_basictools
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
index bb6948e610..9227dd0537 100644
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
+++ b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
@@ -1,31 +1,13 @@
# Generated from extrafilters.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_extrafilters LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+# special case skip regeneration
qt_add_plugin(pnp_extrafilters)
target_sources(pnp_extrafilters PRIVATE
extrafiltersplugin.cpp extrafiltersplugin.h
)
set_target_properties(pnp_extrafilters PROPERTIES
- WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
+ LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/app"
)
target_include_directories(pnp_extrafilters PUBLIC
../../app
@@ -38,7 +20,6 @@ target_link_libraries(pnp_extrafilters PUBLIC
)
install(TARGETS pnp_extrafilters
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}/plugins"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}/plugins"
)
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
index 51025b7100..36c8695ae9 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
@@ -66,12 +66,13 @@
#include <QAction>
#include <QClipboard>
#include <QContextMenuEvent>
+#include <QFont>
+#include <QFontDatabase>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QFormLayout>
-#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QRegularExpressionMatchIterator>
@@ -106,6 +107,20 @@ static QString codeToPattern(QString code)
return code;
}
+static QFrame *createHorizontalSeparator()
+{
+ auto *result = new QFrame;
+ result->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ return result;
+}
+
+static QFrame *createVerticalSeparator()
+{
+ auto *result = new QFrame;
+ result->setFrameStyle(QFrame::VLine | QFrame::Sunken);
+ return result;
+}
+
class PatternLineEdit : public QLineEdit
{
Q_OBJECT
@@ -239,6 +254,7 @@ void RegularExpressionDialog::setResultUiEnabled(bool enabled)
{
matchDetailsTreeWidget->setEnabled(enabled);
namedGroupsTreeWidget->setEnabled(enabled);
+ replacementTextEdit->setEnabled(enabled);
}
static void setTextColor(QWidget *widget, const QColor &color)
@@ -264,6 +280,7 @@ void RegularExpressionDialog::refresh()
matchDetailsTreeWidget->clear();
namedGroupsTreeWidget->clear();
regexpStatusLabel->setText(QString());
+ replacementTextEdit->clear();
if (pattern.isEmpty()) {
setResultUiEnabled(false);
@@ -271,12 +288,12 @@ void RegularExpressionDialog::refresh()
return;
}
- QRegularExpression rx(pattern);
- if (!rx.isValid()) {
+ regularExpression.setPattern(pattern);
+ if (!regularExpression.isValid()) {
setTextColor(patternLineEdit, Qt::red);
regexpStatusLabel->setText(tr("Invalid: syntax error at position %1 (%2)")
- .arg(rx.patternErrorOffset())
- .arg(rx.errorString()));
+ .arg(regularExpression.patternErrorOffset())
+ .arg(regularExpression.errorString()));
setResultUiEnabled(false);
setUpdatesEnabled(true);
return;
@@ -308,11 +325,13 @@ void RegularExpressionDialog::refresh()
if (useUnicodePropertiesOptionCheckBox->isChecked())
patternOptions |= QRegularExpression::UseUnicodePropertiesOption;
- rx.setPatternOptions(patternOptions);
+ regularExpression.setPatternOptions(patternOptions);
- const int capturingGroupsCount = rx.captureCount() + 1;
+ const int capturingGroupsCount = regularExpression.captureCount() + 1;
- QRegularExpressionMatchIterator iterator = rx.globalMatch(text, offsetSpinBox->value(), matchType, matchOptions);
+ const int offset = offsetSpinBox->value();
+ QRegularExpressionMatchIterator iterator =
+ regularExpression.globalMatch(text, offset, matchType, matchOptions);
int i = 0;
while (iterator.hasNext()) {
@@ -334,7 +353,7 @@ void RegularExpressionDialog::refresh()
regexpStatusLabel->setText(tr("Valid"));
- const QStringList namedCaptureGroups = rx.namedCaptureGroups();
+ const QStringList namedCaptureGroups = regularExpression.namedCaptureGroups();
for (int i = 0; i < namedCaptureGroups.size(); ++i) {
const QString currentNamedCaptureGroup = namedCaptureGroups.at(i);
@@ -343,28 +362,44 @@ void RegularExpressionDialog::refresh()
namedGroupItem->setText(1, currentNamedCaptureGroup.isNull() ? tr("<no name>") : currentNamedCaptureGroup);
}
+ updateReplacement();
setUpdatesEnabled(true);
}
-void RegularExpressionDialog::setupUi()
+void RegularExpressionDialog::updateReplacement()
{
- QWidget *leftHalfContainer = setupLeftUi();
-
- QFrame *verticalSeparator = new QFrame;
- verticalSeparator->setFrameStyle(QFrame::VLine | QFrame::Sunken);
-
- QWidget *rightHalfContainer = setupRightUi();
+ replacementTextEdit->clear();
+ const QString &replacement = replacementLineEdit->text();
+ if (!regularExpression.isValid() || replacement.isEmpty())
+ return;
- QHBoxLayout *mainLayout = new QHBoxLayout;
- mainLayout->addWidget(leftHalfContainer);
- mainLayout->addWidget(verticalSeparator);
- mainLayout->addWidget(rightHalfContainer);
+ QString replaced = subjectTextEdit->toPlainText();
+ replaced.replace(regularExpression, replacement);
+ replacementTextEdit->setPlainText(replaced);
+}
- setLayout(mainLayout);
+void RegularExpressionDialog::setupUi()
+{
+ auto *mainLayout = new QVBoxLayout(this);
+ mainLayout->addWidget(setupTextUi());
+ mainLayout->addWidget(createHorizontalSeparator());
+ auto *horizontalLayout = new QHBoxLayout();
+ mainLayout->addLayout(horizontalLayout);
+ horizontalLayout->addWidget(setupOptionsUi());
+ horizontalLayout->addWidget(createVerticalSeparator());
+ horizontalLayout->addWidget(setupInfoUi());
+
+ auto font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+ patternLineEdit->setFont(font);
+ rawStringLiteralLineEdit->setFont(font);
+ escapedPatternLineEdit->setFont(font);
+ replacementLineEdit->setFont(font);
+ subjectTextEdit->setFont(font);
+ replacementTextEdit->setFont(font);
}
-QWidget *RegularExpressionDialog::setupLeftUi()
+QWidget *RegularExpressionDialog::setupTextUi()
{
QWidget *container = new QWidget;
@@ -387,6 +422,35 @@ QWidget *RegularExpressionDialog::setupLeftUi()
subjectTextEdit = new QPlainTextEdit;
layout->addRow(tr("&Subject text:"), subjectTextEdit);
+ layout->addRow(createHorizontalSeparator());
+
+ QLabel *replaceLabel = new QLabel(tr("<h3>Replacement"));
+ layout->addRow(replaceLabel);
+
+ replacementLineEdit = new QLineEdit;
+ replacementLineEdit->setClearButtonEnabled(true);
+ connect(replacementLineEdit, &QLineEdit::textChanged, this,
+ &RegularExpressionDialog::updateReplacement);
+ layout->addRow(tr("&Replace by:"), replacementLineEdit);
+ replacementLineEdit->setToolTip(tr("Use \\1, \\2... as placeholders for the captured groups."));
+
+ replacementTextEdit = new QPlainTextEdit;
+ replacementTextEdit->setReadOnly(true);
+ layout->addRow(tr("Result:"), replacementTextEdit);
+
+ return container;
+}
+
+QWidget *RegularExpressionDialog::setupOptionsUi()
+{
+ QWidget *container = new QWidget;
+
+ QFormLayout *layout = new QFormLayout(container);
+ layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+ layout->setContentsMargins(QMargins());
+
+ layout->addRow(new QLabel(tr("<h3>Options</h3>")));
+
caseInsensitiveOptionCheckBox = new QCheckBox(tr("Case insensitive (/i)"));
dotMatchesEverythingOptionCheckBox = new QCheckBox(tr("Dot matches everything (/s)"));
multilineOptionCheckBox = new QCheckBox(tr("Multiline (/m)"));
@@ -431,7 +495,7 @@ QWidget *RegularExpressionDialog::setupLeftUi()
return container;
}
-QWidget *RegularExpressionDialog::setupRightUi()
+QWidget *RegularExpressionDialog::setupInfoUi()
{
QWidget *container = new QWidget;
@@ -447,9 +511,7 @@ QWidget *RegularExpressionDialog::setupRightUi()
matchDetailsTreeWidget->setSizeAdjustPolicy(QTreeWidget::AdjustToContents);
layout->addRow(tr("Match details:"), matchDetailsTreeWidget);
- QFrame *horizontalSeparator = new QFrame;
- horizontalSeparator->setFrameStyle(QFrame::HLine | QFrame::Sunken);
- layout->addRow(horizontalSeparator);
+ layout->addRow(createHorizontalSeparator());
QLabel *regexpInfoLabel = new QLabel(tr("<h3>Regular expression information</h3>"));
layout->addRow(regexpInfoLabel);
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.h b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
index b0db4d884c..b5d592c3c2 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.h
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
@@ -54,6 +54,7 @@
#define REGULAREXPRESSIONDIALOG_H
#include <QDialog>
+#include <QRegularExpression>
QT_BEGIN_NAMESPACE
class QCheckBox;
@@ -72,18 +73,25 @@ class RegularExpressionDialog : public QDialog
public:
RegularExpressionDialog(QWidget *parent = nullptr);
+private slots:
+ void updateReplacement();
+
private:
void refresh();
void setupUi();
QWidget *setupLeftUi();
- QWidget *setupRightUi();
+ QWidget *setupTextUi();
+ QWidget *setupOptionsUi();
+ QWidget *setupInfoUi();
void setResultUiEnabled(bool enabled);
QLineEdit *patternLineEdit;
QLineEdit *rawStringLiteralLineEdit;
QLineEdit *escapedPatternLineEdit;
+ QLineEdit *replacementLineEdit;
QPlainTextEdit *subjectTextEdit;
+ QPlainTextEdit *replacementTextEdit;
QCheckBox *caseInsensitiveOptionCheckBox;
QCheckBox *dotMatchesEverythingOptionCheckBox;
@@ -104,6 +112,8 @@ private:
QLabel *regexpStatusLabel;
QTreeWidget *namedGroupsTreeWidget;
+
+ QRegularExpression regularExpression;
};
#endif
diff --git a/examples/widgets/tools/settingseditor/settingstree.cpp b/examples/widgets/tools/settingseditor/settingstree.cpp
index 04af8ce3b9..bcbf3744a5 100644
--- a/examples/widgets/tools/settingseditor/settingstree.cpp
+++ b/examples/widgets/tools/settingseditor/settingstree.cpp
@@ -214,7 +214,7 @@ void SettingsTree::updateChildItems(QTreeWidgetItem *parent)
if (value.userType() == QMetaType::UnknownType) {
child->setText(1, "Invalid");
} else {
- if (value.type() == QVariant::String) {
+ if (value.typeId() == QMetaType::QString) {
const QString stringValue = value.toString();
if (m_typeChecker->boolExp.match(stringValue).hasMatch()) {
value.setValue(stringValue.compare("true", Qt::CaseInsensitive) == 0);
diff --git a/examples/widgets/touch/CMakeLists.txt b/examples/widgets/touch/CMakeLists.txt
index d2c3152ad8..ca6ef7fcb8 100644
--- a/examples/widgets/touch/CMakeLists.txt
+++ b/examples/widgets/touch/CMakeLists.txt
@@ -3,7 +3,7 @@
if(NOT TARGET Qt::Widgets)
return()
endif()
-add_subdirectory(pinchzoom)
-add_subdirectory(fingerpaint)
-add_subdirectory(knobs)
-add_subdirectory(dials)
+qt_internal_add_example(pinchzoom)
+qt_internal_add_example(fingerpaint)
+qt_internal_add_example(knobs)
+qt_internal_add_example(dials)
diff --git a/examples/widgets/touch/fingerpaint/scribblearea.cpp b/examples/widgets/touch/fingerpaint/scribblearea.cpp
index 7af565ff30..2e6e532afb 100644
--- a/examples/widgets/touch/fingerpaint/scribblearea.cpp
+++ b/examples/widgets/touch/fingerpaint/scribblearea.cpp
@@ -196,11 +196,11 @@ bool ScribbleArea::event(QEvent *event)
case QEvent::TouchEnd:
{
const QTouchEvent *touch = static_cast<QTouchEvent *>(event);
- const QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
+ const auto touchPoints = static_cast<QTouchEvent *>(event)->points();
for (const QTouchEvent::TouchPoint &touchPoint : touchPoints) {
switch (touchPoint.state()) {
- case Qt::TouchPointStationary:
- case Qt::TouchPointReleased:
+ case QEventPoint::Stationary:
+ case QEventPoint::Released:
// don't do anything if this touch point hasn't moved or has been released
continue;
default:
diff --git a/examples/widgets/touch/knobs/knob.cpp b/examples/widgets/touch/knobs/knob.cpp
index 659ba82f45..eb64b56ceb 100644
--- a/examples/widgets/touch/knobs/knob.cpp
+++ b/examples/widgets/touch/knobs/knob.cpp
@@ -77,11 +77,11 @@ bool Knob::sceneEvent(QEvent *event)
{
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
- if (touchEvent->touchPoints().count() == 2) {
- const QTouchEvent::TouchPoint &touchPoint1 = touchEvent->touchPoints().first();
- const QTouchEvent::TouchPoint &touchPoint2 = touchEvent->touchPoints().last();
+ if (touchEvent->points().count() == 2) {
+ const QEventPoint &touchPoint1 = touchEvent->points().first();
+ const QEventPoint &touchPoint2 = touchEvent->points().last();
- QLineF line1(touchPoint1.lastScenePos(), touchPoint2.lastScenePos());
+ QLineF line1(touchPoint1.sceneLastPosition(), touchPoint2.sceneLastPosition());
QLineF line2(touchPoint1.scenePosition(), touchPoint2.scenePosition());
setTransform(QTransform().rotate(line2.angleTo(line1)), true);
diff --git a/examples/widgets/touch/pinchzoom/graphicsview.cpp b/examples/widgets/touch/pinchzoom/graphicsview.cpp
index e1ce42f93f..5ad3f9152b 100644
--- a/examples/widgets/touch/pinchzoom/graphicsview.cpp
+++ b/examples/widgets/touch/pinchzoom/graphicsview.cpp
@@ -68,15 +68,15 @@ bool GraphicsView::viewportEvent(QEvent *event)
case QEvent::TouchEnd:
{
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
- QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
+ const auto touchPoints = touchEvent->points();
if (touchPoints.count() == 2) {
// determine scale factor
- const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
- const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
+ const QEventPoint &touchPoint0 = touchPoints.first();
+ const QEventPoint &touchPoint1 = touchPoints.last();
qreal currentScaleFactor =
QLineF(touchPoint0.position(), touchPoint1.position()).length()
/ QLineF(touchPoint0.pressPosition(), touchPoint1.pressPosition()).length();
- if (touchEvent->touchPointStates() & Qt::TouchPointReleased) {
+ if (touchEvent->touchPointStates() & QEventPoint::Released) {
// if one of the fingers is released, remember the current scale
// factor so that adding another finger later will continue zooming
// by adding new scale factor to the existing remembered value.
diff --git a/examples/widgets/tutorials/CMakeLists.txt b/examples/widgets/tutorials/CMakeLists.txt
index c2fa4a81d7..733eb42151 100644
--- a/examples/widgets/tutorials/CMakeLists.txt
+++ b/examples/widgets/tutorials/CMakeLists.txt
@@ -4,4 +4,4 @@ add_subdirectory(addressbook)
add_subdirectory(widgets)
add_subdirectory(modelview)
add_subdirectory(gettingStarted)
-add_subdirectory(notepad)
+qt_internal_add_example(notepad)
diff --git a/examples/widgets/tutorials/addressbook/CMakeLists.txt b/examples/widgets/tutorials/addressbook/CMakeLists.txt
index a8823d059a..cb00cbc084 100644
--- a/examples/widgets/tutorials/addressbook/CMakeLists.txt
+++ b/examples/widgets/tutorials/addressbook/CMakeLists.txt
@@ -1,9 +1,9 @@
# Generated from addressbook.pro.
-add_subdirectory(part1)
-add_subdirectory(part2)
-add_subdirectory(part3)
-add_subdirectory(part4)
-add_subdirectory(part5)
-add_subdirectory(part6)
-add_subdirectory(part7)
+qt_internal_add_example(part1)
+qt_internal_add_example(part2)
+qt_internal_add_example(part3)
+qt_internal_add_example(part4)
+qt_internal_add_example(part5)
+qt_internal_add_example(part6)
+qt_internal_add_example(part7)
diff --git a/examples/widgets/tutorials/gettingStarted/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/CMakeLists.txt
index 2aa8163029..42cac47b96 100644
--- a/examples/widgets/tutorials/gettingStarted/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/CMakeLists.txt
@@ -1,2 +1 @@
-# Generated from gettingStarted.pro.
-
+add_subdirectory(gsQt)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt
index 7a9ade8511..8302fd7598 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from gsqt.pro.
-add_subdirectory(part1)
-add_subdirectory(part2)
-add_subdirectory(part3)
-add_subdirectory(part4)
-add_subdirectory(part5)
+qt_internal_add_example(part1)
+qt_internal_add_example(part2)
+qt_internal_add_example(part3)
+qt_internal_add_example(part4)
+qt_internal_add_example(part5)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt
index e2877a26ba..13ed19067b 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part1.pro.
cmake_minimum_required(VERSION 3.14)
-project(part1 LANGUAGES CXX)
+project(getting_started_part1 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part1
+qt_add_executable(getting_started_part1
main.cpp
)
-set_target_properties(part1 PROPERTIES
+set_target_properties(getting_started_part1 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part1 PUBLIC
+target_link_libraries(getting_started_part1 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part1
+install(TARGETS getting_started_part1
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt
index 65a3ff3539..4f72a9ede8 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part2.pro.
cmake_minimum_required(VERSION 3.14)
-project(part2 LANGUAGES CXX)
+project(getting_started_part2 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part2
+qt_add_executable(getting_started_part2
main.cpp
)
-set_target_properties(part2 PROPERTIES
+set_target_properties(getting_started_part2 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part2 PUBLIC
+target_link_libraries(getting_started_part2 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part2
+install(TARGETS getting_started_part2
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt
index 4a9b79b00b..d8a72abd59 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part3.pro.
cmake_minimum_required(VERSION 3.14)
-project(part3 LANGUAGES CXX)
+project(getting_started_part3 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part3
+qt_add_executable(getting_started_part3
main.cpp
)
-set_target_properties(part3 PROPERTIES
+set_target_properties(getting_started_part3 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part3 PUBLIC
+target_link_libraries(getting_started_part3 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part3
+install(TARGETS getting_started_part3
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt
index b1b224c70d..3e42635ae4 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part4.pro.
cmake_minimum_required(VERSION 3.14)
-project(part4 LANGUAGES CXX)
+project(getting_started_part4 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part4
+qt_add_executable(getting_started_part4
main.cpp
)
-set_target_properties(part4 PROPERTIES
+set_target_properties(getting_started_part4 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part4 PUBLIC
+target_link_libraries(getting_started_part4 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part4
+install(TARGETS getting_started_part4
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt
index 182c2e9a48..c92f60d535 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part5.pro.
cmake_minimum_required(VERSION 3.14)
-project(part5 LANGUAGES CXX)
+project(getting_started_part5 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part5
+qt_add_executable(getting_started_part5
main.cpp
)
-set_target_properties(part5 PROPERTIES
+set_target_properties(getting_started_part5 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part5 PUBLIC
+target_link_libraries(getting_started_part5 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part5
+install(TARGETS getting_started_part5
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingstartedqt.qdoc b/examples/widgets/tutorials/gettingstartedqt.qdoc
index 32e8845c05..2edc1f07f1 100644
--- a/examples/widgets/tutorials/gettingstartedqt.qdoc
+++ b/examples/widgets/tutorials/gettingstartedqt.qdoc
@@ -320,13 +320,6 @@
\skipto Notepad::~Notepad
\printuntil }
- In order to have the text edit field occupy the whole screen, we add
- \c setCentralWidget to the main window.
-
- \quotefromfile tutorials/notepad/notepad.cpp
- \skipto Notepad::Notepad(QWidget *parent)
- \printuntil }
-
\section2 Project File
The wizard generates the following project file, \c {notepad.pro}, for
diff --git a/examples/widgets/tutorials/modelview/CMakeLists.txt b/examples/widgets/tutorials/modelview/CMakeLists.txt
index 10f2cf6ecf..49ca672e48 100644
--- a/examples/widgets/tutorials/modelview/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/CMakeLists.txt
@@ -1,9 +1,9 @@
# Generated from modelview.pro.
-add_subdirectory(1_readonly)
-add_subdirectory(2_formatting)
-add_subdirectory(3_changingmodel)
-add_subdirectory(4_headers)
-add_subdirectory(5_edit)
-add_subdirectory(6_treeview)
-add_subdirectory(7_selections)
+qt_internal_add_example(1_readonly)
+qt_internal_add_example(2_formatting)
+qt_internal_add_example(3_changingmodel)
+qt_internal_add_example(4_headers)
+qt_internal_add_example(5_edit)
+qt_internal_add_example(6_treeview)
+qt_internal_add_example(7_selections)
diff --git a/examples/widgets/tutorials/notepad/notepad.cpp b/examples/widgets/tutorials/notepad/notepad.cpp
index 5fd0d69cea..c2491b6030 100644
--- a/examples/widgets/tutorials/notepad/notepad.cpp
+++ b/examples/widgets/tutorials/notepad/notepad.cpp
@@ -72,19 +72,24 @@ Notepad::Notepad(QWidget *parent) :
ui(new Ui::Notepad)
{
ui->setupUi(this);
- this->setCentralWidget(ui->textEdit);
connect(ui->actionNew, &QAction::triggered, this, &Notepad::newDocument);
connect(ui->actionOpen, &QAction::triggered, this, &Notepad::open);
connect(ui->actionSave, &QAction::triggered, this, &Notepad::save);
connect(ui->actionSave_as, &QAction::triggered, this, &Notepad::saveAs);
connect(ui->actionPrint, &QAction::triggered, this, &Notepad::print);
- connect(ui->actionExit, &QAction::triggered, this, &Notepad::exit);
- connect(ui->actionCopy, &QAction::triggered, this, &Notepad::copy);
- connect(ui->actionCut, &QAction::triggered, this, &Notepad::cut);
- connect(ui->actionPaste, &QAction::triggered, this, &Notepad::paste);
- connect(ui->actionUndo, &QAction::triggered, this, &Notepad::undo);
- connect(ui->actionRedo, &QAction::triggered, this, &Notepad::redo);
+ connect(ui->actionExit, &QAction::triggered, this, &QWidget::close);
+#if QT_CONFIG(clipboard)
+ connect(ui->textEdit, &QTextEdit::copyAvailable, ui->actionCopy, &QAction::setEnabled);
+ connect(ui->actionCopy, &QAction::triggered, ui->textEdit, &QTextEdit::copy);
+ connect(ui->actionCut, &QAction::triggered, ui->textEdit, &QTextEdit::cut);
+ connect(ui->actionPaste, &QAction::triggered, ui->textEdit, &QTextEdit::paste);
+#endif
+ connect(ui->textEdit, &QTextEdit::undoAvailable, ui->actionUndo, &QAction::setEnabled);
+ connect(ui->actionUndo, &QAction::triggered, ui->textEdit, &QTextEdit::undo);
+ connect(ui->textEdit, &QTextEdit::redoAvailable, ui->actionRedo, &QAction::setEnabled);
+ connect(ui->actionRedo, &QAction::triggered, ui->textEdit, &QTextEdit::redo);
+
connect(ui->actionFont, &QAction::triggered, this, &Notepad::selectFont);
connect(ui->actionBold, &QAction::triggered, this, &Notepad::setFontBold);
connect(ui->actionUnderline, &QAction::triggered, this, &Notepad::setFontUnderline);
@@ -117,6 +122,8 @@ void Notepad::newDocument()
void Notepad::open()
{
QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
+ if (fileName.isEmpty())
+ return;
QFile file(fileName);
currentFile = fileName;
if (!file.open(QIODevice::ReadOnly | QFile::Text)) {
@@ -136,6 +143,8 @@ void Notepad::save()
// If we don't have a filename from before, get one.
if (currentFile.isEmpty()) {
fileName = QFileDialog::getSaveFileName(this, "Save");
+ if (fileName.isEmpty())
+ return;
currentFile = fileName;
} else {
fileName = currentFile;
@@ -155,6 +164,8 @@ void Notepad::save()
void Notepad::saveAs()
{
QString fileName = QFileDialog::getSaveFileName(this, "Save as");
+ if (fileName.isEmpty())
+ return;
QFile file(fileName);
if (!file.open(QFile::WriteOnly | QFile::Text)) {
@@ -182,42 +193,6 @@ void Notepad::print()
#endif // QT_CONFIG(printer)
}
-void Notepad::exit()
-{
- QCoreApplication::quit();
-}
-
-void Notepad::copy()
-{
-#if QT_CONFIG(clipboard)
- ui->textEdit->copy();
-#endif
-}
-
-void Notepad::cut()
-{
-#if QT_CONFIG(clipboard)
- ui->textEdit->cut();
-#endif
-}
-
-void Notepad::paste()
-{
-#if QT_CONFIG(clipboard)
- ui->textEdit->paste();
-#endif
-}
-
-void Notepad::undo()
-{
- ui->textEdit->undo();
-}
-
-void Notepad::redo()
-{
- ui->textEdit->redo();
-}
-
void Notepad::selectFont()
{
bool fontSelected;
@@ -244,8 +219,7 @@ void Notepad::setFontBold(bool bold)
void Notepad::about()
{
- QMessageBox::about(this, tr("About MDI"),
- tr("The <b>Notepad</b> example demonstrates how to code a basic "
- "text editor using QtWidgets"));
-
+ QMessageBox::about(this, tr("About Notepad"),
+ tr("The <b>Notepad</b> example demonstrates how to code a basic "
+ "text editor using QtWidgets"));
}
diff --git a/examples/widgets/tutorials/notepad/notepad.h b/examples/widgets/tutorials/notepad/notepad.h
index 5e44dfeedc..d4209daf6d 100644
--- a/examples/widgets/tutorials/notepad/notepad.h
+++ b/examples/widgets/tutorials/notepad/notepad.h
@@ -89,18 +89,6 @@ private slots:
void print();
- void exit();
-
- void copy();
-
- void cut();
-
- void paste();
-
- void undo();
-
- void redo();
-
void selectFont();
void setFontBold(bool bold);
diff --git a/examples/widgets/tutorials/notepad/notepad.ui b/examples/widgets/tutorials/notepad/notepad.ui
index 4b2a6a0675..b891dbae46 100644
--- a/examples/widgets/tutorials/notepad/notepad.ui
+++ b/examples/widgets/tutorials/notepad/notepad.ui
@@ -53,8 +53,15 @@
<addaction name="actionRedo"/>
<addaction name="actionFont"/>
</widget>
+ <widget class="QMenu" name="menuAbout">
+ <property name="title">
+ <string>About</string>
+ </property>
+ <addaction name="actionAbout"/>
+ </widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
+ <addaction name="menuAbout"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
@@ -171,8 +178,6 @@
<property name="toolTip">
<string>Exit notepad</string>
</property>
- <property name="shortcut">
- </property>
</action>
<action name="actionCopy">
<property name="icon">
diff --git a/examples/widgets/tutorials/widgets/CMakeLists.txt b/examples/widgets/tutorials/widgets/CMakeLists.txt
index 1f4afee780..fcf0ed9ddd 100644
--- a/examples/widgets/tutorials/widgets/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from widgets.pro.
-add_subdirectory(toplevel)
-add_subdirectory(childwidget)
-add_subdirectory(windowlayout)
-add_subdirectory(nestedlayouts)
+qt_internal_add_example(toplevel)
+qt_internal_add_example(childwidget)
+qt_internal_add_example(windowlayout)
+qt_internal_add_example(nestedlayouts)
diff --git a/examples/widgets/widgets/CMakeLists.txt b/examples/widgets/widgets/CMakeLists.txt
index 8daf6a69ae..34d3d28b67 100644
--- a/examples/widgets/widgets/CMakeLists.txt
+++ b/examples/widgets/widgets/CMakeLists.txt
@@ -1,27 +1,27 @@
# Generated from widgets.pro.
-add_subdirectory(analogclock)
-add_subdirectory(calculator)
-add_subdirectory(calendarwidget)
-add_subdirectory(charactermap)
-add_subdirectory(codeeditor)
-add_subdirectory(digitalclock)
-add_subdirectory(elidedlabel)
-add_subdirectory(groupbox)
-add_subdirectory(icons)
-add_subdirectory(imageviewer)
-add_subdirectory(lineedits)
-add_subdirectory(movie)
-add_subdirectory(mousebuttons)
-add_subdirectory(scribble)
-add_subdirectory(shapedclock)
-add_subdirectory(sliders)
-add_subdirectory(spinboxes)
-add_subdirectory(styles)
-add_subdirectory(stylesheet)
-add_subdirectory(tablet)
-add_subdirectory(tetrix)
-add_subdirectory(tooltips)
-add_subdirectory(validators)
-add_subdirectory(wiggly)
-add_subdirectory(windowflags)
+qt_internal_add_example(analogclock)
+qt_internal_add_example(calculator)
+qt_internal_add_example(calendarwidget)
+qt_internal_add_example(charactermap)
+qt_internal_add_example(codeeditor)
+qt_internal_add_example(digitalclock)
+qt_internal_add_example(elidedlabel)
+qt_internal_add_example(groupbox)
+qt_internal_add_example(icons)
+qt_internal_add_example(imageviewer)
+qt_internal_add_example(lineedits)
+qt_internal_add_example(movie)
+qt_internal_add_example(mousebuttons)
+qt_internal_add_example(scribble)
+qt_internal_add_example(shapedclock)
+qt_internal_add_example(sliders)
+qt_internal_add_example(spinboxes)
+qt_internal_add_example(styles)
+qt_internal_add_example(stylesheet)
+qt_internal_add_example(tablet)
+qt_internal_add_example(tetrix)
+qt_internal_add_example(tooltips)
+qt_internal_add_example(validators)
+qt_internal_add_example(wiggly)
+qt_internal_add_example(windowflags)
diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp
index 23010a6e1a..38e9798d83 100644
--- a/examples/widgets/widgets/calendarwidget/window.cpp
+++ b/examples/widgets/widgets/calendarwidget/window.cpp
@@ -237,6 +237,9 @@ void Window::createPreviewGroupBox()
}
//! [9]
+// TODO: use loc.name() as label (but has underscore in place of slash)
+// TODO: use locale() == loc instead of only comparing language and territory
+// Needs someone familiar with this example to work out ramifications
//! [10]
void Window::createGeneralOptionsGroupBox()
{
@@ -247,16 +250,16 @@ void Window::createGeneralOptionsGroupBox()
int index = 0;
for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
QLocale::Language lang = static_cast<QLocale::Language>(_lang);
- QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang);
- for (int i = 0; i < countries.count(); ++i) {
- QLocale::Country country = countries.at(i);
+ const auto locales =
+ QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyTerritory);
+ for (auto loc : locales) {
QString label = QLocale::languageToString(lang);
+ auto territory = loc.territory();
label += QLatin1Char('/');
- label += QLocale::countryToString(country);
- QLocale locale(lang, country);
- if (this->locale().language() == lang && this->locale().country() == country)
+ label += QLocale::territoryToString(territory);
+ if (locale().language() == lang && locale().territory() == territory)
curLocaleIndex = index;
- localeCombo->addItem(label, locale);
+ localeCombo->addItem(label, loc);
++index;
}
}
diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp
index 0e333b693f..6a1072afef 100644
--- a/examples/widgets/widgets/imageviewer/imageviewer.cpp
+++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp
@@ -151,7 +151,7 @@ bool ImageViewer::saveFile(const QString &fileName)
if (!writer.write(image)) {
QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
tr("Cannot write %1: %2")
- .arg(QDir::toNativeSeparators(fileName)), writer.errorString());
+ .arg(QDir::toNativeSeparators(fileName), writer.errorString()));
return false;
}
const QString message = tr("Wrote \"%1\"").arg(QDir::toNativeSeparators(fileName));
diff --git a/examples/widgets/widgets/stylesheet/mainwindow.cpp b/examples/widgets/widgets/stylesheet/mainwindow.cpp
index a8bd20e964..6e7bb295e1 100644
--- a/examples/widgets/widgets/stylesheet/mainwindow.cpp
+++ b/examples/widgets/widgets/stylesheet/mainwindow.cpp
@@ -76,10 +76,12 @@ void MainWindow::on_editStyleAction_triggered()
void MainWindow::on_aboutAction_triggered()
{
+ const QString url = QStringLiteral("http://doc.qt.io/qt-%1/stylesheet.html")
+ .arg(QT_VERSION_MAJOR);
QMessageBox::about(this, tr("About Style sheet"),
tr("The <b>Style Sheet</b> example shows how widgets can be styled "
- "using <a href=\"http://doc.qt.io/qt-5/stylesheet.html\">Qt "
+ "using <a href=\"%1\">Qt "
"Style Sheets</a>. Click <b>File|Edit Style Sheet</b> to pop up the "
"style editor, and either choose an existing style sheet or design "
- "your own."));
+ "your own.").arg(url));
}
diff --git a/examples/widgets/widgets/validators/localeselector.cpp b/examples/widgets/widgets/validators/localeselector.cpp
index 3dcd04d9ff..3fdf5c6b3b 100644
--- a/examples/widgets/widgets/validators/localeselector.cpp
+++ b/examples/widgets/widgets/validators/localeselector.cpp
@@ -60,18 +60,18 @@ LocaleSelector::LocaleSelector(QWidget *parent)
for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
QLocale::Language lang = static_cast<QLocale::Language>(_lang);
const QList<QLocale> locales =
- QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyCountry);
+ QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyTerritory);
for (const QLocale &l : locales) {
QString label = QLocale::languageToString(l.language());
label += QLatin1Char('/');
- label += QLocale::countryToString(l.country());
- // distinguish locales by script, if there are more than one script for a language/country pair
- if (QLocale::matchingLocales(l.language(), QLocale::AnyScript, l.country()).size() > 1)
+ label += QLocale::territoryToString(l.territory());
+ // distinguish locales by script, if there are more than one script for a language/territory pair
+ if (QLocale::matchingLocales(l.language(), QLocale::AnyScript, l.territory()).size() > 1)
label += QLatin1String(" (") + QLocale::scriptToString(l.script()) + QLatin1Char(')');
addItem(label, QVariant::fromValue(l));
- if (l.language() == locale().language() && l.country() == locale().country()
+ if (l.language() == locale().language() && l.territory() == locale().territory()
&& (locale().script() == QLocale::AnyScript || l.script() == locale().script())) {
curIndex = index;
}