Miscellaneous
Miscellaneous
Add Icon (CMake)
We first need to prepare our .ico file :
- Create a
.pngwith a size of 64x64 - Download 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.rcwith the following line inside :IDI_ICON1 ICON DISCARDABLE "path/to/icon/icon.ico" - Open your
CMakescript 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
- Some terminals may not support colors (like CMD on Windows).
- If you try to enable colors, you will see gibberish around your message.
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
qDebug() can still be used. They will have the log level as header.