From 76523fc28a498637d2c75eb14e134eb5c741996f Mon Sep 17 00:00:00 2001 From: androiddrew Date: Wed, 30 May 2018 16:21:27 -0400 Subject: [PATCH] Refactored project directories. \r\n Working hello world application in cm-ui --- README.md | 3 +++ cm-lib/cm-lib.pro | 23 +++++++++++++++---- cm-lib/{ => source}/cm-lib_global.h | 0 cm-lib/{ => source/models}/client.cpp | 0 cm-lib/{ => source/models}/client.h | 0 cm-tests/cm-tests.pro | 8 +++++-- cm-tests/{ => source/models}/client-tests.cpp | 0 cm-ui/cm-ui.pro | 17 +++++++++----- cm-ui/{ => source}/main.cpp | 2 +- cm-ui/{qml.qrc => views.qrc} | 2 +- cm-ui/{ => views}/main.qml | 0 11 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 README.md rename cm-lib/{ => source}/cm-lib_global.h (100%) rename cm-lib/{ => source/models}/client.cpp (100%) rename cm-lib/{ => source/models}/client.h (100%) rename cm-tests/{ => source/models}/client-tests.cpp (100%) rename cm-ui/{ => source}/main.cpp (83%) rename cm-ui/{qml.qrc => views.qrc} (61%) rename cm-ui/{ => views}/main.qml (100%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..45f9786 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# CM QT Application + +This is a sample QT application from the Learn QT 5 book. It follows the Model, View, Controller pattern and utilizes the Unit Testing. diff --git a/cm-lib/cm-lib.pro b/cm-lib/cm-lib.pro index 5391f57..d477601 100644 --- a/cm-lib/cm-lib.pro +++ b/cm-lib/cm-lib.pro @@ -4,11 +4,22 @@ # #------------------------------------------------- +# Its a lib so we can exclud gui module QT -= gui +# the name we want to give our binary output. so cm-lib.dll in this case +# if we don't provide a TARGET it will default to the project name, which is exactly, +# what we have here. So we are being explicit TARGET = cm-lib + +# Not an app. It's a lib so that is our template TEMPLATE = lib +# We want to add the c++14 features to our project so that is what we are going with +CONFIG += c++14 + +# we use this flag to trigger the export of the cm-lib_global.h which is a file with +# preprocessor boilerplate we can use to export our shared library symbols. DEFINES += CMLIB_LIBRARY # The following define makes your compiler emit warnings if you use @@ -22,12 +33,14 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -SOURCES += \ - client.cpp +# Adding our source folder so that the path is searched when we use #include statements +INCLUDEPATH += source + +SOURCES += source\models\client.cpp +#unix style SOURCES += source/models/client.cpp -HEADERS += \ - client.h \ - cm-lib_global.h +HEADERS += source\cm-lib_global.h source\models\client.h +#unix style HEADERS += source/cm-lib_global.h source/modeles/client.h unix { target.path = /usr/lib diff --git a/cm-lib/cm-lib_global.h b/cm-lib/source/cm-lib_global.h similarity index 100% rename from cm-lib/cm-lib_global.h rename to cm-lib/source/cm-lib_global.h diff --git a/cm-lib/client.cpp b/cm-lib/source/models/client.cpp similarity index 100% rename from cm-lib/client.cpp rename to cm-lib/source/models/client.cpp diff --git a/cm-lib/client.h b/cm-lib/source/models/client.h similarity index 100% rename from cm-lib/client.h rename to cm-lib/source/models/client.h diff --git a/cm-tests/cm-tests.pro b/cm-tests/cm-tests.pro index c7a0b64..78e81e9 100644 --- a/cm-tests/cm-tests.pro +++ b/cm-tests/cm-tests.pro @@ -4,11 +4,14 @@ # #------------------------------------------------- +# gives us access to the Qt Test features QT += testlib QT -= gui TARGET = client-tests + +CONFIG += c++14 CONFIG += console CONFIG -= app_bundle @@ -25,6 +28,7 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 +INCLUDEPATH += source -SOURCES += \ - client-tests.cpp \ No newline at end of file +SOURCES += source\models\client-tests.cpp +#unix style SOURCES += sources/models/client-tests.cpp diff --git a/cm-tests/client-tests.cpp b/cm-tests/source/models/client-tests.cpp similarity index 100% rename from cm-tests/client-tests.cpp rename to cm-tests/source/models/client-tests.cpp diff --git a/cm-ui/cm-ui.pro b/cm-ui/cm-ui.pro index 7777113..67568b4 100644 --- a/cm-ui/cm-ui.pro +++ b/cm-ui/cm-ui.pro @@ -1,5 +1,8 @@ -QT += quick -CONFIG += c++11 +# Since out UI is written in QML we need both the QML and Quick modules +QT += qml quick + +TEMPLATE = app +CONFIG += c++14 # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings @@ -12,13 +15,15 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -SOURCES += \ - main.cpp +INCLUDEPATH += source + +SOURCES += source/main.cpp +#unix style SOURCES += source/main.cpp -RESOURCES += qml.qrc +RESOURCES += views.qrc # Additional import path used to resolve QML modules in Qt Creator's code model -QML_IMPORT_PATH = +QML_IMPORT_PATH = $$PWD # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = diff --git a/cm-ui/main.cpp b/cm-ui/source/main.cpp similarity index 83% rename from cm-ui/main.cpp rename to cm-ui/source/main.cpp index 6333b85..c9d90c7 100644 --- a/cm-ui/main.cpp +++ b/cm-ui/source/main.cpp @@ -8,7 +8,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/views/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; diff --git a/cm-ui/qml.qrc b/cm-ui/views.qrc similarity index 61% rename from cm-ui/qml.qrc rename to cm-ui/views.qrc index 5f6483a..65df798 100644 --- a/cm-ui/qml.qrc +++ b/cm-ui/views.qrc @@ -1,5 +1,5 @@ - main.qml + views/main.qml diff --git a/cm-ui/main.qml b/cm-ui/views/main.qml similarity index 100% rename from cm-ui/main.qml rename to cm-ui/views/main.qml