Andrew Moa Blog Site

Dependency Issues of CPack

Previously, when using CPack to package a QML program, I noticed that the files installed by the CPack package differed significantly from those installed using the cmake install command. Below, I will explain and resolve this issue.

1. Problem code

Let’s take the previously written QML program as an example. To facilitate code improvements, the CMakeLists.txt is rewritten as follows, with dependency installation and packaging modules written separately into cmake/dependencies.cmake and cmake/packaging.cmake.

8 minutes to read
Andrew Moa

Handling Event Callback Functions with Lambda Expressions

C++11 began supporting lambda expressions. Besides being used as anonymous functions, lambda expressions can also access variables in the surrounding environment through a capture list. In UI programming, using lambda expressions instead of traditional function pointers for handling callback functions can not only simplify the code and improve readability but also reduce parameter passing and increase flexibility. Below, we attempt to implement related operations for commonly used C++ UI libraries.
19 minutes to read
Andrew Moa

Exploring implementation methods for separating interface and methods

Separating the program’s UI from the implementation code of its methods is very helpful for improving development efficiency and code readability. Mainstream UI libraries such as Qt, wxWidgets, and GTK each have their own implementation approaches, which will be demonstrated below.

1. wxWidgets project based on XRC

1.1 Write XRC file

wxWidgets supports defining the UI through XML format and saving it as an XRC file. Using XRC files allows for separating the interface from the code, but the downside is that the released program will be slightly larger compared to the non-XRC version.

14 minutes to read
Andrew Moa