summaryrefslogtreecommitdiffstats
path: root/examples/widgets/graphicsview/elasticnodes
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/graphicsview/elasticnodes')
-rw-r--r--examples/widgets/graphicsview/elasticnodes/CMakeLists.txt34
-rw-r--r--examples/widgets/graphicsview/elasticnodes/graphwidget.cpp4
-rw-r--r--examples/widgets/graphicsview/elasticnodes/node.cpp4
3 files changed, 23 insertions, 19 deletions
diff --git a/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt b/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt
index b10f11a45c..07299cd5a7 100644
--- a/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt
+++ b/examples/widgets/graphicsview/elasticnodes/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(elasticnodes LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/elasticnodes")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(elasticnodes
edge.cpp edge.h
graphwidget.cpp graphwidget.h
@@ -23,14 +20,21 @@ set_target_properties(elasticnodes PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(elasticnodes PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(elasticnodes PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS elasticnodes
- 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 elasticnodes
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
index 3d8ca8e972..ede3d23137 100644
--- a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
@@ -123,11 +123,11 @@ void GraphWidget::timerEvent(QTimerEvent *event)
nodes << node;
}
- for (Node *node : qAsConst(nodes))
+ for (Node *node : std::as_const(nodes))
node->calculateForces();
bool itemsMoved = false;
- for (Node *node : qAsConst(nodes)) {
+ for (Node *node : std::as_const(nodes)) {
if (node->advancePosition())
itemsMoved = true;
}
diff --git a/examples/widgets/graphicsview/elasticnodes/node.cpp b/examples/widgets/graphicsview/elasticnodes/node.cpp
index fd8df0b32b..eb102f0aa4 100644
--- a/examples/widgets/graphicsview/elasticnodes/node.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/node.cpp
@@ -67,7 +67,7 @@ void Node::calculateForces()
//! [4]
// Now subtract all forces pulling items together
double weight = (edgeList.size() + 1) * 10;
- for (const Edge *edge : qAsConst(edgeList)) {
+ for (const Edge *edge : std::as_const(edgeList)) {
QPointF vec;
if (edge->sourceNode() == this)
vec = mapToItem(edge->destNode(), 0, 0);
@@ -148,7 +148,7 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
{
switch (change) {
case ItemPositionHasChanged:
- for (Edge *edge : qAsConst(edgeList))
+ for (Edge *edge : std::as_const(edgeList))
edge->adjust();
graph->itemMoved();
break;