summaryrefslogtreecommitdiffstats
path: root/examples/sql/drilldown
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sql/drilldown')
-rw-r--r--examples/sql/drilldown/CMakeLists.txt36
-rw-r--r--examples/sql/drilldown/imageitem.cpp6
-rw-r--r--examples/sql/drilldown/imageitem.h3
-rw-r--r--examples/sql/drilldown/images/qt-creator.pngbin6655 -> 8355 bytes
-rw-r--r--examples/sql/drilldown/images/qt-logo.pngbin5527 -> 6650 bytes
-rw-r--r--examples/sql/drilldown/images/qt-project.pngbin16832 -> 8376 bytes
-rw-r--r--examples/sql/drilldown/images/qt-quick.pngbin26635 -> 8029 bytes
-rw-r--r--examples/sql/drilldown/informationwindow.cpp14
-rw-r--r--examples/sql/drilldown/informationwindow.h8
-rw-r--r--examples/sql/drilldown/main.cpp2
-rw-r--r--examples/sql/drilldown/view.cpp4
-rw-r--r--examples/sql/drilldown/view.h3
12 files changed, 35 insertions, 41 deletions
diff --git a/examples/sql/drilldown/CMakeLists.txt b/examples/sql/drilldown/CMakeLists.txt
index 9b46be55e0..fb9b441fa3 100644
--- a/examples/sql/drilldown/CMakeLists.txt
+++ b/examples/sql/drilldown/CMakeLists.txt
@@ -1,16 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(drilldown LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/drilldown")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
+qt_standard_project_setup()
+
qt_add_executable(drilldown
../connection.h
imageitem.cpp imageitem.h
@@ -24,11 +21,11 @@ set_target_properties(drilldown PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(drilldown PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
+target_link_libraries(drilldown PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
)
# Resources:
@@ -47,7 +44,14 @@ qt_add_resources(drilldown "drilldown"
)
install(TARGETS drilldown
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET drilldown
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/drilldown/imageitem.cpp b/examples/sql/drilldown/imageitem.cpp
index 59f1255f9f..4dfb5ee6e8 100644
--- a/examples/sql/drilldown/imageitem.cpp
+++ b/examples/sql/drilldown/imageitem.cpp
@@ -54,7 +54,7 @@ void ImageItem::setFrame(int frame)
QPointF center = boundingRect().center();
setTransform(QTransform::fromTranslate(center.x(), center.y()), true);
- setTransform(QTransform::fromScale(1 + frame / 330.0, 1 + frame / 330.0), true);
+ setTransform(QTransform::fromScale(1 + frame / 300.0, 1 + frame / 300.0), true);
setTransform(QTransform::fromTranslate(-center.x(), -center.y()), true);
}
//! [3]
@@ -62,8 +62,8 @@ void ImageItem::setFrame(int frame)
//! [4]
void ImageItem::adjust()
{
- setTransform(QTransform::fromScale(120 / boundingRect().width(),
- 120 / boundingRect().height()));
+ setTransform(QTransform::fromScale(120.0 / boundingRect().width(),
+ 120.0 / boundingRect().height()));
}
//! [4]
diff --git a/examples/sql/drilldown/imageitem.h b/examples/sql/drilldown/imageitem.h
index f6be4d50ab..23a41aa2f2 100644
--- a/examples/sql/drilldown/imageitem.h
+++ b/examples/sql/drilldown/imageitem.h
@@ -11,7 +11,6 @@
class ImageItem : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
-
public:
enum { Type = UserType + 1 };
@@ -25,7 +24,7 @@ protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
-private slots:
+private Q_SLOTS:
void setFrame(int frame);
void updateItemPosition();
diff --git a/examples/sql/drilldown/images/qt-creator.png b/examples/sql/drilldown/images/qt-creator.png
index 0602bdcad1..576f9f39ff 100644
--- a/examples/sql/drilldown/images/qt-creator.png
+++ b/examples/sql/drilldown/images/qt-creator.png
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-logo.png b/examples/sql/drilldown/images/qt-logo.png
index 7603fa0c90..fb8b1686bd 100644
--- a/examples/sql/drilldown/images/qt-logo.png
+++ b/examples/sql/drilldown/images/qt-logo.png
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-project.png b/examples/sql/drilldown/images/qt-project.png
index e066fbe3f9..8c20e3f0c2 100644
--- a/examples/sql/drilldown/images/qt-project.png
+++ b/examples/sql/drilldown/images/qt-project.png
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-quick.png b/examples/sql/drilldown/images/qt-quick.png
index 90d9fd075d..a905f47c35 100644
--- a/examples/sql/drilldown/images/qt-quick.png
+++ b/examples/sql/drilldown/images/qt-quick.png
Binary files differ
diff --git a/examples/sql/drilldown/informationwindow.cpp b/examples/sql/drilldown/informationwindow.cpp
index 4f9896d74d..d69c91d0cb 100644
--- a/examples/sql/drilldown/informationwindow.cpp
+++ b/examples/sql/drilldown/informationwindow.cpp
@@ -9,9 +9,9 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items,
: QDialog(parent)
{
//! [0] //! [1]
- QLabel *itemLabel = new QLabel(tr("Item: "));
- QLabel *descriptionLabel = new QLabel(tr("Description: "));
- QLabel *imageFileLabel = new QLabel(tr("Image file: "));
+ QLabel *itemLabel = new QLabel(tr("Item:"));
+ QLabel *descriptionLabel = new QLabel(tr("Description:"));
+ QLabel *imageFileLabel = new QLabel(tr("Image file:"));
createButtons();
@@ -37,12 +37,8 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items,
//! [3]
//! [4]
- connect(descriptionEditor, &QTextEdit::textChanged, [=]() {
- enableButtons();
- });
- connect(imageFileEditor, &QComboBox::currentIndexChanged, [=]() {
- enableButtons();
- });
+ connect(descriptionEditor, &QTextEdit::textChanged, this, [this]() { enableButtons(true); });
+ connect(imageFileEditor, &QComboBox::currentIndexChanged, this, [this]() { enableButtons(true); });
QFormLayout *formLayout = new QFormLayout;
formLayout->addRow(itemLabel, itemText);
diff --git a/examples/sql/drilldown/informationwindow.h b/examples/sql/drilldown/informationwindow.h
index 368d99c303..2380463785 100644
--- a/examples/sql/drilldown/informationwindow.h
+++ b/examples/sql/drilldown/informationwindow.h
@@ -11,22 +11,20 @@
class InformationWindow : public QDialog
{
Q_OBJECT
-
public:
InformationWindow(int id, QSqlRelationalTableModel *items,
QWidget *parent = nullptr);
-
int id() const;
-signals:
+Q_SIGNALS:
void imageChanged(int id, const QString &fileName);
//! [0]
//! [1]
-private slots:
+private Q_SLOTS:
void revert();
void submit();
- void enableButtons(bool enable = true);
+ void enableButtons(bool enable);
//! [1]
//! [2]
diff --git a/examples/sql/drilldown/main.cpp b/examples/sql/drilldown/main.cpp
index 5828a37aab..77b8725281 100644
--- a/examples/sql/drilldown/main.cpp
+++ b/examples/sql/drilldown/main.cpp
@@ -11,8 +11,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(drilldown);
-
QApplication app(argc, argv);
if (!createConnection())
diff --git a/examples/sql/drilldown/view.cpp b/examples/sql/drilldown/view.cpp
index f41d32f282..c2f7301a21 100644
--- a/examples/sql/drilldown/view.cpp
+++ b/examples/sql/drilldown/view.cpp
@@ -87,8 +87,8 @@ void View::showInformation(ImageItem *image)
if (!window) {
window = new InformationWindow(id, itemTable, this);
- connect(window, QOverload<int,const QString &>::of(&InformationWindow::imageChanged),
- this, QOverload<int,const QString &>::of(&View::updateImage));
+ connect(window, &InformationWindow::imageChanged,
+ this, &View::updateImage);
window->move(pos() + QPoint(20, 40));
window->show();
diff --git a/examples/sql/drilldown/view.h b/examples/sql/drilldown/view.h
index acbfeb1558..f44dedce99 100644
--- a/examples/sql/drilldown/view.h
+++ b/examples/sql/drilldown/view.h
@@ -14,7 +14,6 @@ class InformationWindow;
class View : public QGraphicsView
{
Q_OBJECT
-
public:
View(const QString &items, const QString &images, QWidget *parent = nullptr);
@@ -23,7 +22,7 @@ protected:
//! [0]
//! [1]
-private slots:
+private Q_SLOTS:
void updateImage(int id, const QString &fileName);
//! [1]