Code of samples above:
-
Design parametrization widgets in the blink of an eye
- Handles typed parameters, with straightforward GUI
-
Easy handling of data containers using GUI tables
-
Easy progress feedback of algorithms with GUI
-
Can transform an existing C++ program into a GUI application with minimum modifications (details)
-
Requires only Qt to be installed
-
Single header available
-
The library is designed as a general C++ toolkit with straightforward bindings with Qt
-
Modularity by relying on template specializations
-
Tutorials available in this page
-
Doxygen documentation available here
Glove is a C++/Qt library aiming at creating simple interfaces. It proposes several basic GUI features that are often necessary to develop a user-friendly program. The toolkit aims at minimizing the required knowledge of Qt. For now, the main features of the library are:
-
The management of parameters
-
Table/tree interfacing with data containers
-
A progress feedback tracking
-
Files management (read and write)
The library consists in an alternative to Qt UI for simple prototypes (QtCreator is not required). It is particularly suited for developpers wishing to create a basic graphical user interface (input/output) of their program or algorithm without needing in-depth knowledge of Qt. A minimal understanding of widgets may be required depending on the use of the library.
The library is separated in two layers.
-
Sleeve
-
Slv prefix
-
C++ only
-
Can compile without Qt
-
-
Glove
-
Glv prefix
-
Qt layer interpreting the Sleeve layer for interfacing
-
The library can be used either:
-
by using a single header. See details
-
by installation and direct use of sources and compiled libraires. See details
Aims at providing a simple framework for parametrization of class instances, by inheriting a dedicated class. Creating the parametrization interface using Qt widgets is straightforward.
The framework explicitly points what are the parameters of a class. Parameters are defined by:
- a variable name
- a type
- a name
- a comment
- a default value
- optional rules on its value
A parametrization can currently contain up to 24 parameters of any type. Parametrizations can contain nested parametrizations. So there is theoretically no limit to the number of parameters.
Each parametrization widget GlvParametrizationWidget
and data widget GlvWidget
can be extended easily with an input/output file interface.
You can find the list of type specializations provided in the library here GlvWidgetData_specs.md.
See this page for a custom specialization.
List of convenient macros to handle parametrizations.
-
glvm_parametrization
:-
Declare a parametrization
-
see this page for example
-
-
glvm_get_parameter_GlvWidget(_parametrization_widget, _parameter_index)
:- Get the
GlvWidget
associated to parameter_parameter_index
- Get the
-
glvm_get_parameter_GlvWidgetData(_parametrization_widget, _parameter_index)
:-
Get the parameter widget (ex: QSpinBox) associated to parameter
_parameter_index
-
see this page for example
-
-
glvm_SlvEnum
/glvm_SlvEnum_named
:
The framework includes simple methods to transform a C++ program with command line arguments into a basic application. The features that can be easily added are:
- Input arguments through a GUI
- Show and control progression of loops.
- Show status messages
Details at Glove application
The framework includes a data modeling extra layer for view and edition. The class GlvTableView.h allows visualization of data as tables provided their modeling is defined. The modelings are implemented in specializations. Some specializations related to common containers are already available and listed at Model specializations.
The table view can handle data of multiple dimensions, using different containers, while displaying a handy interface for view and edition.
A progress interface is proposed in the library. Running an algorithm in a separate thread and monitoring its progress is made easy. You can find examples below of how to use the interface.
Filesystem : C++11 compatible. Does not need boost.
The list of the key classes that are specialized can be found here
The library can be used either:
-
Option 1 : by adding a single header to a qmake or cmake project
- Does not require compilation of Glove.
-
Option 2 : by compiling and installing includes and compiled binaries,
- then use the installed components in a CMake project
The second option allows parsimonious include of headers and faster compilation of the code.
The file glove.h available in release can be simply included in sources. The management of Qt can be disabled by using the macro GLOVE_DISABLE_QT
.
To enable the json management, the macro GLOVE_ENABLE_JSON
must be defined.
To enable the management of boost containers, the macro GLOVE_ENABLE_BOOST
must be defined.
To enable use of glove application GlvApp across shared libraries, GLOVE_APP_SHARED
and GLOVE_APP_SHARED_EXPORT
must be defined.
The latter to be defined in the shared library.
#define GLOVE_DISABLE_QT // Option to disable Qt management
#define GLOVE_ENABLE_JSON // Option to enable Json management
#define GLOVE_ENABLE_BOOST // Option to enable boost containers management
#define GLOVE_APP_SHARED // Option to use GlvApp in a shared library
#define GLOVE_APP_SHARED_EXPORT // If GLOVE_APP_SHARED is set, to define in the shared library
#include "glove.h"
The file glove.h must be added to the CMake or qmake .pro file.
An example project using the single header is proposed here.
The installation only requires CMake and Qt to be installed.
At the root of the library, using PowerShell:
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022"
- In the field
Where is the source code
, select the root folder of the library. That is, where CMakeLists.txt is. - In the field
Where to build the binaries
, select thebuild
folder (to create yourself). - Press
Configure
- Press
Generate
Open Glove.sln
, and compile the INSTALL
target.
The library will install to build/install
.
- The default installation path is
/usr/local
.- The library will install in:
/usr/local/lib/glove
/usr/local/include/glove
- The library will install in:
- The default build type is Release if
-DCMAKE_BUILD_TYPE
is not specified.
At the root of the library:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make install
- The
make install
command may requiresudo make install
depending on privileges to install the library in/usr/local/
. - To install at a specific location, use
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/path/where/to/install
- For instance
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=.
will install the library in the current build directory under./install
After compilation, all the executable examples using the library can be found in the directory build/samples
.
Set the environment variable GLOVE_ROOT
as the path where the library was installed. That is, in the example above, build/install
.
For this purpose, in the search field of Windows, select "Environment variables". Then in the User variables
part, press New
.
If -DCMAKE_INSTALL_PREFIX:PATH=/path/where/to/install
was used at CMake generation, then it is required to
set the environment variable GLOVE_ROOT
as the path where the library was installed. For instance, build/install
.
For this purpose, edit the file ~/.bashrc
by adding the line: export GLOVE_ROOT=/path/where/to/install
. The full path must be set (i.e. not relative to the library build directory).
An example project using the installed library is proposed here.
Copy CMake/FindGlove.cmake to a folder named /CMake/CMakeModules
at the root of your CMake project.
In the CMakeLists.txt, add where to look for FindGlove.cmake
by setting
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake/CMakeModules")
Then set:
find_package(Glove)
In CMake's INCLUDE_DIRECTORIES
, add ${GLOVE_INCLUDE_DIRS}
.
foreach(lib ${GLOVE_LIBRARIES})
target_link_libraries(${PROJECT_NAME} optimized ${lib})
endforeach()
foreach(lib ${GLOVE_LIBRARIES_DEBUG})
target_link_libraries(${PROJECT_NAME} debug ${lib})
endforeach()
The library is licensed as GNU GPLv3. Dual licensing with commercial license is possible on demand.