#QtnProperty This is user and programmist friendly properties for Qt framework #Overview There are some limitations of standard Qt property system. This project is an attempt to make better properties for programmist and user. The key features are:
- Properties hierarchy (properties can be organized in hierarchy at any depth)
- Property widget to observe and edit properties in uniform way
- Signals before and after property has changed
- Property description - short text which help user to understand meaning and purpose of the property
- Property state - property can be disabled or hidden at any moment
- Serialization via QDataStream
- Set/Get property value to/from QVariant and QString
- Scripting support
- Delegates to customize look and feel properties in property widget
- PEG (property/enum generator) - it's tool like Qt moc which generates properties hierarchy from QML like files.
Here are screenshots of the Demo application:
#How to build Requirements:
- Qt 5.2 framework
- Flex 2.5.37 and Bison 2.7 (for Windows can be found here)
To build:
mkdir path_to_build
cd path_to_build
qmake path_to_QtnProperty/Property.pro -r
make
Generated libraries and executables will be placed into the 'path_to_build/bin' folder. Precomiled libraries and Demo application you can download here
To run tests and demo:
cd path_to_build/bin
./QtnPropertyTests
./QtnPropertyDemo
QtnProperty project consisit of five submodules:
- QtnPropertyCore library - property classes (non GUI stuff)
- QtnPropertyWidget library - QtnPropertyWidget, QtnPropertyView and property delegates (GUI stuff)
- QtnPEG tool - executable to generate C++ code for propert sets from simple QML like files (*.pef files)
- QtnPropertyTests - tests for QtnPropertyCore library
- QtnPropertyDemo - demo application
#How to use
- Write *.pef file with propertyset declaration. For example TextEditor.pef:
#include "Core/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;
}
}
-
Generate C++ classes by running command (to use *.pef files in your project see PEG.pri)
./QtnPEG TextEditor.pef
-
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);