diff options
Diffstat (limited to 'examples/widgets/tutorials/modelview/3_changingmodel')
3 files changed, 27 insertions, 20 deletions
diff --git a/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt b/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt index 0b99f28682..1b8dd84c92 100644 --- a/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt +++ b/examples/widgets/tutorials/modelview/3_changingmodel/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(mv_changingmodel LANGUAGES CXX) -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/3_changingmodel") - find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) +qt_standard_project_setup() + qt_add_executable(mv_changingmodel main.cpp mymodel.cpp mymodel.h @@ -21,14 +18,21 @@ set_target_properties(mv_changingmodel PROPERTIES MACOSX_BUNDLE TRUE ) -target_link_libraries(mv_changingmodel PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets +target_link_libraries(mv_changingmodel PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS mv_changingmodel - 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 mv_changingmodel + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.cpp b/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.cpp index 82ba17dc45..5ce56632ff 100644 --- a/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.cpp +++ b/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.cpp @@ -44,9 +44,9 @@ QVariant MyModel::data(const QModelIndex &index, int role) const //! [quoting mymodel_b ] void MyModel::timerHit() { - //we identify the top left cell + // we identify the top left cell QModelIndex topLeft = createIndex(0,0); - //emit a signal to make the view reread identified data + // emit a signal to make the view reread identified data emit dataChanged(topLeft, topLeft, {Qt::DisplayRole}); } //! [quoting mymodel_b ] diff --git a/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.h b/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.h index 70a32f10be..5fab806c42 100644 --- a/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.h +++ b/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.h @@ -11,14 +11,17 @@ class MyModel : public QAbstractTableModel { Q_OBJECT public: - MyModel(QObject *parent = nullptr); + explicit MyModel(QObject *parent = nullptr); + int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; -private: - QTimer *timer; + private slots: void timerHit(); + +private: + QTimer *timer; }; #endif // MYMODEL_H |