This is user and programmer friendly properties for Qt framework. See wiki for some details.
There are some limitations of standard Qt property system. This project is an attempt to make better properties. The key features are:
New Features in v2.0.0
Some screenshots of the Demo application:
Requirements:
To build:
mkdir path_to_build
cd path_to_build
qmake path_to_QtnProperty/QtnProperty.pro -r
make
Or just open path_to_QtnProperty/QtnProperty.pro file in Qt Creator and build all. Generated libraries and executables will be placed into the target specific folders. For example:
bin-linux-gcc-x86_64
bin-osx-clang-x86_64
bin-win32-msvc-i386
bin-win32-msvc-clang-x86_64
bin-win32-gcc-i386
bin-win32-gcc-x86_64
To run tests and demo, go to one of the binary folders and run:
./QtnPropertyTests
./QtnPropertyDemo
QtnProperty project consists of four submodules:
To have QtnProperty in your project you should include QtnPropertyDepend.pri file into your pro file. Example:
TEMPLATE = subdirs
SUBDIRS += \
QtnProperty \
Application
QtnProperty.file = path_to/QtnProperty/QtnProperty.pro
Application.depends = \
QtnProperty
QT += core gui widgets script
TEMPLATE = app
include(path_to/QtnProperty/QtnPropertyDepend.pri)
# this will add QtnProperty root to include path and will link the library to your app.
Then you can manually create property sets in your C++ code, create QtnPropertyWidget or QtnPropertyView widgets and assign property set to the widget:
class Ui_MainWindow
{
public:
QtnPropertyWidget *centralWidget;
...
};
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_propertySet = new QtnPropertySet(this)
auto floatValue = qtnCreateProperty<QtnPropertyFloat>(m_propertySet);
floatValue->setName("value");
floatValue->setDisplayName(tr("Value"));
floatValue->setDescription(tr("Float value"));
floatValue->setMaxValue(1.f);
floatValue->setMinValue(0.f);
floatValue->setStepValue(0.1f);
floatValue->setValue(0.3f);
auto textColor = qtnCreateProperty<QtnPropertyQColor>(m_propertySet);
textColor->setName("textColor");
textColor->setDisplayName(tr("TextColor"));
textColor->setDescription(tr("Foreground text color"));
textColor->setValue(QColor(0, 0, 0));
ui->centralWidget->setPropertySet(m_propertySet);
}
This example will show you something like this:
If you want to use *.pef files to generate properties C++ code you need to build QtnPEG executable.
To use *.pef files in your project you should do the following in your pro file:
include(path_to/QtnProperty/PEG/PEG.pri)
PEG_SOURCES += TextEditor.pef
Write .pef file with propertyset declaration. See [wiki](https://github.com/qtinuum/QtnProperty/wiki/Property-Enum-file-format-(.pef)) for more info. For example TextEditor.pef:
#include "QtnProperty/PropertyCore.h"
property_set TextEditor
{
Bool enableWrapping
{
description = "Enable/disable text wrapping";
value = true;
}
Bool replaceTabsWithSpaces
{
description = "Automatically replace tabs with spaces";
value = false;
slot propertyDidChange
{
tabSize.switchState(QtnPropertyStateImmutable, !replaceTabsWithSpaces);
}
}
UInt tabSize
{
description = "Number of spaces to be placed.";
state = QtnPropertyStateImmutable;
value = 4;
}
}
Include generated TextEditor.peg.h and TextEditor.peg.cpp files into your project.
Now you can use QtnPropertySetTextEditor class (defined in generated files) in your C++ code like this:
QtnPropertySetTextEditor params;
params.enableWrapping = false;
if (params.replaceTabsWithSpaces)
document.replaceTabsWithSpaces(params.tabSize);
Video of GUI testing using Froglogic (c) Squish test framework is here.