This is a project where I am learning the basics of Qt through building a simple cross-platform Desktop TODO application.
- Building
- Tests
- Snapcraft
- VSCode Files
This project was developed on Linux, but it should be able to be built on macOS and Windows. All that's needed is a C++ development environment (c++ compiler, make/nmake/msbuild) and a development installation of Qt4 or Qt5. Note that either Qt4 or Qt5 should work, but this application was tested using Qt5 on Linux and Qt4 on Windows.
Make sure that the compiler being used supports C++11 or later, because features added in this standard are being used in the application.
-
qmake
orqmake-qt4
orqmake-qt5
, depending on what version of Qt you want to compile under. -
make
-
Run with
./build/qt-todo
Qt4 is a hassle to set up now that it's no longer supported. I will update these instructions when I have tested the application against Qt5.
These instructions are for Visual Studio. I have built it on Visual Studio 2019, but it should work on any version newer than 2010 that includes a compiler that supports C++11. I would have included instructions for how to build on MinGW/Cygwin, but I have not had the time to attempt these methods.
-
In a developer command prompt where you have Qt4's bin files on the path, enter
qmake -tp vc
while in theqt-todo
folder. -
Open the generated .vcxproj with Visual Studio.
-
It should prompt to update the project to the latest version of Visual Studio. Accept this offer.
-
Build/run the project as normal. If you need to make changes to the qt-todo.pro or add/remove files, you will need to regenerate the Visual Studio project. (At least, I find regenerating the project is the easiest method, because this means no manual editing of the .vcxproj to get Visual Studio to run the correct preprocessing commands).
The testing framework Catch2 is used to unit test some of the list classes. Currently there is no automatic testing of any GUI elements. TravisCI is configured to run the test suite automatically on each push to the master branch. So far, it only tests under Linux.
WARNING: The checked in test suite creates the folders and file
~/.config/qt-todo/setting
. If you have a file there currently
(such as settings for this or other programs), it will be overwritten
without warning.
To run the test suite, follow these steps:
- Download the latest release of
catch2.hpp
from the Catch2 Github - Put the file into the
testing
folder - Run
qmake test=1
in order to set up the testing Makefile - Run
make
in order to build the testing program - Run
./testing/qt-todo
in order to run the tests
- Download the latest release of
catch2.hpp
from the Catch2 Github - Put the file into the
testing
folder - Run
qmake -tp vc test=1
in order to create the test Visual Studio project - Open the project, then retarget it
- Build the project
- Run the generated .exe in a Command Prompt/Powershell/Windows Terminal in order to view the results of the tests.
Please refer to the Catch2 documentation on how to use Catch2 to write tests. I am using the convention of making an additional file for each class I am testing, so please refer to the documentation on how to structure these files. Here is the current process for testing a class that is not yet being tested:
- Make a new file under the folder
testing
calledtest_myClass.cpp
, where MyClass is the class being tested. - Follow the steps in the RUNNING TESTS section in order to run the added tests.
This application is available on the Snap Store. This will allow for an easier installation across Linux distributions. The repository is set up to automatically build and deploy Snaps when there is a push to the master branch.
If you are intending to add new features to qt-todo, then it may be necessary
to modify snap/snapcraft.yaml
. This is because of the Snap sandboxing. You
will need to declare slots for every time you wish to access a restricted system
feature. Please refer to the
Snapcraft Documentation for more information.
If you have added new slots, you should test to make sure that the snap build
works. You can build the snap on your computer if you have snapcraft installed by
running snapcraft --debug
in the root of the project. It will take a
while to build, because it needs to make a Ubuntu VM in order to build the
snap. Once it is built, you can install it with
sudo snap install (name).snap --dangerous
in order to test.
I have included VSCode build tasks for the program in order to help anyone else
who wants to build the application and happens to be using VSCode. They are
currently set up to use the default Qt make (qmake
) and only work on Linux.
The tasks that are intended to be run directly are build-app
, build-test
,
and build-snap
. I put them all under the 'Build' section of Tasks so that
they can be run with the Ctrl+Shift+B
shortcut