
QPropertyEditor
Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net
This small library is used to be a lightweight method to allow the graphical editing of properties defined via the Q_PROPERTY macro. It can be easily extended for custom datatypes.
In the zip archiv a Sample Application is included that contains a custom property for a vector with three floating point values.
Feedback is welcome!
12 years ago
v 0.1. support for basic datatypes
v 0.2. support for dynamic properties (that don't start with a '_')
v 0.3 support for enums (thanks to banal from qt-apps.org for this enhancement)
12 years ago
v 0.1. support for basic datatypes
v 0.2. support for dynamic properties (that don't start with a '_')
v 0.3 support for enums (thanks to banal from qt-apps.org for this enhancement)
phamtv
10 years ago
Report
phamtv
10 years ago
Class Name
...Registers
->...0x01-Register 1...........0xFF
->->... Bit 1 - Some thing.....0x01
->->... Bit 2 - Some thing.....0x00
->...0x02-Register 2...........0xAB
->->... Bit 1 - Some thing.....0x01
->->... Bit 2 - Some thing.....0x00
->->... Bit 3 - Some thing.....0x00
etc..
Thanks!
Report
phamtv
10 years ago
Class Name
...Registers
->...0x01-Register 1...........0xFF
->->... Bit 1 - Some thing.....0x01
->->... Bit 2 - Some thing.....0x00
->...0x02-Register 2...........0xAB
->->... Bit 1 - Some thing.....0x01
->->... Bit 2 - Some thing.....0x00
->->... Bit 3 - Some thing.....0x00
etc..
Thanks!
Report
starapple
11 years ago
Should it be built/made? I tried to make it and got this message: error: 'INT_MAX' was not declared in this scope Property.cpp:69
D:/Qt/QPropertyEditor_0.3/src/QPropertyEditor/Property.cpp
I executed the dos batch file in the Doc folder but it did nothing.
Thanks for your help.
Report
Volki
10 years ago
You have to include limits.h if you couldn't find INT_MAX. The docs batch file only works if you have doxygen installed and available through your PATH environment settings
Report
jacmoe
11 years ago
Great library. :)
I noticed that the license for the code is LGPL, but the headers mention GPL.
Is that an error?
Is it LGPL or GPL ?
I changed the license headers in my copy to the following:
// *************************************************************************************************
//
// QPropertyEditor v 0.3
//
// --------------------------------------
// Copyright (C) 2007 Volker Wiendl
// Acknowledgements to Roman alias banal from qt-apps.org for the Enum enhancement
//
//
// The QPropertyEditor Library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with
// this program; if not, write to the Free Software Foundation, Inc., 59 Temple
// Place - Suite 330, Boston, MA 02111-1307, USA, or go to
// http://www.gnu.org/copyleft/lesser.txt.
//
// *************************************************************************************************
I hope it's alright with you.
Otherwise, you need to change the entry so that the right license is shown.
Kind Regards
Jacob 'jacmoe' Moen
Report
Volki
11 years ago
Report
jong
11 years ago
I cannot manage to set a name for a property. It is possible to do it with the class as the example shows it however I didn't find a way to change the displayed name of a property, looking at the code didn't help me.
Report
Volki
11 years ago
Report
sajis997
11 years ago
I have already installed your component.
My system crashed couple of days ago and i reinstalled everything.
While compiling this component i have the following error:
INT_MAX not declared
I have queries regarding that before as well and some in forum said that
#include <limits> has defined that
But i am still having that error
Any hint would be of great help
Regards
Sajjad
Report
muenalan
12 years ago
Q: Can we add a setting to update only once the editing is finshed; not during editing. After ENTER, for a QLineEdit, for instance.
Background: During editing a property value the underlaying m_property member of the QObject class gets *immediately* updated (not just after finishing the edit). So when writing an email, for instance, its also written during entering the string, while the email is half correct/valid.
PROBLEM: My class checks for valid emails, and voila throws exeptions. Of course, there are more cases where half-correct input is not ok.
Thanks+Cheers,
mu
Report
muenalan
11 years ago
Property.cpp.editingFinishedInsteadOfsetValue-DIFFPATCH
49,70d48
< void Property::editingFinished()
< {
< if( QObject::sender() )
< {
< QVariant value_editor;
<
< switch(value().type())
< {
< case QVariant::Int:
< value_editor = static_cast<QSpinBox *>( QObject::sender() )->value();
< break;
< case QMetaType::Float:
< case QVariant::Double:
< value_editor = static_cast<QDoubleSpinBox *>( QObject::sender() )->value();
< break;
< }
<
< if (m_propertyObject)
< m_propertyObject->setProperty(qPrintable(objectName()), value_editor);
< }
< }
<
91d68
<
96,103c73
<
< // MUE: In 0.3 valueChanged(..) was setting the property upon each character change, even when
< // the input was not meant to be set.
< // Changed to editingFinished() (see QAbstractSpinBox docs) and introduced corresponding slot into
< // this class.
<
< // connect(editor, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
< connect(editor, SIGNAL(editingFinished()), this, SLOT(editingFinished()));
---
> connect(editor, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
110,111c80
< // connect(editor, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
< connect(editor, SIGNAL(editingFinished()), this, SLOT(editingFinished()));
---
> connect(editor, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
Property.h.editingFinishedInsteadOfsetValue-DIFFPATCH
140a141,142
> void editingFinished();
>
Report
Volki
11 years ago
Report
muenalan
11 years ago
Report
dostowalla
12 years ago
There is a createEditor() function both in Property and QVariantDelegate class
and i would like to understand the difference betwen each of these
Regards
Sajjad
Report
dostowalla
12 years ago
I am trying to read a node database along
with their respective field structures
Each field of different type.
The Nodes are already loaded from the database in a tree view.
When the user click on one of the nodes
the respective field with different types of that node will be loaded as well. and the user can edit them the mechanism is already provided in that!. Thanks to Volki again.
What changes do i have to make to get what i would like to have
Please let me know if anyone need more explanation to that issue
Regards
Sajjad
Report
Volki
12 years ago
Not sure if that's the answer to your question, if not you have to make a little bit more clear, what's your problem.
Report
dostowalla
12 years ago
I am quite new to Qt and have a question
inside the createEditor() function
there is a function called setProperty()
where there is a variant passed INT_MAX
I did not really understand that; Should that not be declared somewhere?
Report
subik
12 years ago
solves it
Report
ZaphodB
12 years ago
#include <QtGUI/QComboBox>
to
#include <QtGui/QComboBox>
Otherwise you can't compile it under Linux.
Thanks. I was looking for a long time for a tool like that :)
Report
Volki
12 years ago
Report
banal
12 years ago
Thanks a lot for sharing this Widget. It is exactly what i was looking for.
It seems, that i found a Bug and i wasn't really able to track it down myself. Maybe you can help me out :)
Whenever i use a int property in conjunction with the editorhints via Q_CLASSINFO, the editor (QSpinBox) changes it's value to 1 upon editing. If i don't use the editorhints, everything works fine, but then i'm not able to limit my input range.
Another "Feature" i'd like to see is the correct handling of properties that are using enums (declared with Q_ENUMS). In that case, a QComboBox should be used as editor instead of a QSpinBox.
My plan is to:
subclass Property and create a class "EnumProperty".
extend the QPropertyModel::addItem method to automatically create a EnumProperty whenever a enumerable property is detected
Do you think that might work? Or am i missing something important?
Any input is greatly appreciated. If you like, i'll share any modifications with you/the community.
Report
Volki
12 years ago
The only thing I can think of, is that you are using Linux. If I remember correctly, the values were not accepted if you just leave the focus. You had to press return. But that might be a problem in Qt itself or the user interface concept of KDE. I don't know.
Regarding the Q_ENUMS, that shouldn't be a big problem to add.
Report
banal
12 years ago
Here is what i used:
Q_PROPERTY(int Channels READ channels WRITE setChannels DESIGNABLE true USER true)
Q_CLASSINFO("Channels", "minimum=1;maximum=4;singleStep=1;")
The min and max do work as expected, so does the singleStep Parameter. However it always resets my value to 1 when i enter "edit" mode (eg. double click on the item or tab through the list).
I just checked with double values and it doesn't work either whereas in your example application it works...
I really can't spot the difference between my implementation and your TestClass. Except that my object is loaded as a plugin... but that shouldn't affect anything.
Report
Volki
12 years ago
Report