InputFormDialog provides a simple multi-type input dialog for Qt5

cpp, pyside2, python, qt
pip install input-form-dialog==1.0.1



InputFormDialog is a simple library that provides a multi-type input dialog for Qt5.

The purpose of the InputFormDialog is to compliment the static get methods of the QInputDialog such as QInputDialog::getText or QInputDialog::getInt.


Using InputFormDialog is simple. First create a FormData object that will define the form entries and their default values.

The FormData behaves similar to an std::map, new entries are added to it by using the subscript operator FormData::operator[]. The provided key will be used by the dialog as the label and the edit widget will be chosen based on the value type.

Currently the following input queries are supported:

  • boolean
  • color
  • numeric
  • text
  • options list
  • 2d/3d vector

Second, call the modal FormData::getInput function by passing the reference to the data object. If the user accepts the dialog then the data object will hold the new values chosen by the user.

To retrieve the new values from FormData you should use the templated FormData::at method. This method will try and cast the widget value to the desired type. Note that in a debug build if the provided key does not exist or the cast is impossible then an assertion will be raised.

Additionally, you might want to create FormOptions object and specify some of the options that control the properties of widgets used by the dialog.

Currently the following options are available:

  • set numeric limits, step and precision
  • set whether combo box or radio button group is used
  • set whether the combo box / radio button group returns current item text or index


#include "InputFormDialog.h"

// Define form inputs
InputFormDialog::FormData data;
data["Bool"] = true;
data["Color"] = QColor("red");
data["Int"] = 1;
data["String"] = "Test";
data["ComboBox"] = QStringList() << "One" << "Two";
data["Vector2"] = QVector2D(10.0, 5.0);

// Define form options
InputFormDialog::FormOptions options;
options.listDisplaysAsRadios = true;
options.listReturnsIndex = true;

// Ask user for input and retrieve data
if (InputFormDialog::getInput("Example", data, options))
    qDebug() <<<bool>("Bool");
    qDebug() <<<QColor>("Color");
    qDebug() <<<int>("Int");
    qDebug() <<<QString>("String");
    qDebug() <<<int>("ComboBox");
    qDebug() <<<QVector2D>("Vector2");