Miscellaneous#
Add Icon (CMake)#
We first need to prepare our .ico
file :
Create a
.png
with a size of 64x64Download and install ImageMagick’s convert tool
From a command prompt, run
magick convert nameofpng.png nameoficon.ico
You now have your icon file.
Create a file
appicon.rc
with the following line inside :IDI_ICON1 ICON DISCARDABLE "path/to/icon/icon.ico"
Open your
CMake
script and, underadd_executable()
, add"path/to/script.rc"
Your program should now create your .exe with your icon packed !
Logger#
If you want to have a simple, well-formatted, automatic file location, timestamp’ed logger, the following repo contains two files that can be included in your Qt project (they are standalones files).

To use it, call installFormattedColorOutput(bool usecolor);
at the beginning of your main.
Note
Note
Enabling it will also modify the behavior of qDebug(), qInfo() ...
while adding a (colored) header stating the current debug level.
Afterward, simply use one of the provided macro to log your messages with information in which file and on which line the statement is located :
FDEBUG("Debug msg");
FINFO("Info msg");
FWARN("Warn msg");
FCRITICAL("Critical msg");
FFATAL("Fatal msg");
FLN(); // for simple line return without debug data
Standard Qt functions like qDebug()
can still be used. They will have the log level as header.