Skip to content
/ glove Public

C++ Qt library for easy graphical user interfaces

License

Notifications You must be signed in to change notification settings

piallai/glove

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Glove

License: GPLv3 Maintenance Generic badge Qt5 Single header Generic badge Generic badge Generic badge




Teaser

Code of samples above:

Summary

What it does

  • 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)

How

  • 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

Table of contents

  1. Presentation
  2. Features
    1. Class parametrization : automatic widgets
      1. Paradigm
      2. Examples
      3. Save/load interface
      4. Remarks
        1. Widget specializations
        2. Convenient macros
    2. Glove application
    3. Table interfacing
      1. Examples
    4. Progress feedback
      1. Examples
    5. Files I/O
    6. Specializations overview
  3. Use Glove
    1. Single header
    2. Installation and CMake use
      1. Windows / Visual Studio
      2. Linux
    3. Usage
      1. Library location
      2. CMake configuration of a project using Glove
  4. License

Presentation

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

    • moc management using CMake or qmake is still required
  • by installation and direct use of sources and compiled libraires. See details

Class parametrization : automatic widgets

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.

Paradigm

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.

Examples :

Save/load interface

Each parametrization widget GlvParametrizationWidget and data widget GlvWidget can be extended easily with an input/output file interface.

Examples :

Remarks

GlvWidgetData specializations

You can find the list of type specializations provided in the library here GlvWidgetData_specs.md.

See this page for a custom specialization.

Convient macros

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
  • 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:

    • Declare an enum compatible with glove

    • see here and here for example

Glove Application

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

Table interfacing

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.

Examples :

Progress feedback

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.

Examples :

Files I/O

Filesystem : C++11 compatible. Does not need boost.

Examples :

Specializations overview

The list of the key classes that are specialized can be found here

Use Glove

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.

Single header (option 1)

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.

Installation and CMake use (option 2)

The installation only requires CMake and Qt to be installed.

Windows / Visual Studio
Option 1 : CMake command line

At the root of the library, using PowerShell:

mkdir build
cd build
cmake .. -G "Visual Studio 17 2022"
Option 2 : CMake GUI
  • 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 the build folder (to create yourself).
  • Press Configure
  • Press Generate
Generated project

Open Glove.sln, and compile the INSTALL target. The library will install to build/install.

Linux
  • The default installation path is /usr/local.
    • The library will install in:
      • /usr/local/lib/glove
      • /usr/local/include/glove
  • 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 require sudo 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
Examples

After compilation, all the executable examples using the library can be found in the directory build/samples.

Usage

Library location
Windows

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.

Linux

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).

CMake configuration of a project using Glove

An example project using the installed library is proposed here.

Find library

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)
Include

In CMake's INCLUDE_DIRECTORIES, add ${GLOVE_INCLUDE_DIRS}.

Link
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()

License

The library is licensed as GNU GPLv3. Dual licensing with commercial license is possible on demand.