fix: resolve Q_CLASSINFO metadata for child properties by matching all path segments
resloveMetaData() only matched Q_CLASSINFO against the first segment of
the property path (e.g. "ptPosition" from "ptPosition.x"), so child
handles like x/y under a QPointF tree never picked up Min/Max/Step
metadata declared with Q_CLASSINFO("x", ...). This caused the x/y
NumberBox editors to fall back to numeric_limits min/max, clamping
negative values to ~0.
Now iterates path segments from most specific (last) to least specific
(first), so child property names correctly match their Q_CLASSINFO
annotations.
Also add Q_CLASSINFO("x"/"y", "Min=-1000,Max=1000,Step=1") on
GraphicsTextItem to constrain position editing to a reasonable range.
This commit is contained in:
parent
e63fae92c8
commit
e1671fdbe3
|
|
@ -42,10 +42,15 @@ QPropertyHandle::QPropertyHandle(QObject* inParent, QMetaType inType, QString in
|
||||||
void QPropertyHandle::resloveMetaData()
|
void QPropertyHandle::resloveMetaData()
|
||||||
{
|
{
|
||||||
auto metaObj = parent()->metaObject();
|
auto metaObj = parent()->metaObject();
|
||||||
auto firstField = getPropertyPath().split(".").first();
|
const QStringList pathSegments = getPropertyPath().split(".");
|
||||||
|
|
||||||
|
// Try each segment from most specific (last) to least specific (first)
|
||||||
|
for (int seg = pathSegments.size() - 1; seg >= 0; --seg) {
|
||||||
|
const QString& fieldName = pathSegments[seg];
|
||||||
|
if (fieldName.isEmpty()) continue;
|
||||||
for (int i = 0; i < metaObj->classInfoCount(); i++) {
|
for (int i = 0; i < metaObj->classInfoCount(); i++) {
|
||||||
auto metaClassInfo = metaObj->classInfo(i);
|
auto metaClassInfo = metaObj->classInfo(i);
|
||||||
if (metaClassInfo.name() == firstField) {
|
if (metaClassInfo.name() == fieldName) {
|
||||||
QStringList fields = QString(metaClassInfo.value()).split(",", Qt::SplitBehaviorFlags::SkipEmptyParts);
|
QStringList fields = QString(metaClassInfo.value()).split(",", Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||||
for (auto field : fields) {
|
for (auto field : fields) {
|
||||||
QStringList pair = field.split("=");
|
QStringList pair = field.split("=");
|
||||||
|
|
@ -62,6 +67,7 @@ void QPropertyHandle::resloveMetaData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QPropertyHandle* QPropertyHandle::Find(const QObject* inParent, const QString& inPropertyPath)
|
QPropertyHandle* QPropertyHandle::Find(const QObject* inParent, const QString& inPropertyPath)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ class GraphicsTextItem : public AbstractShapeType<QGraphicsTextItem>,
|
||||||
public IPropertyGroupProvider
|
public IPropertyGroupProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_CLASSINFO("x", "Min=-1000,Max=1000,Step=1,Group=ptPosition")
|
||||||
|
Q_CLASSINFO("y", "Min=-1000,Max=1000,Step=1,Group=ptPosition")
|
||||||
|
|
||||||
Q_PROPERTY(QString text READ toPlainText WRITE setPlainText)
|
Q_PROPERTY(QString text READ toPlainText WRITE setPlainText)
|
||||||
Q_PROPERTY(QPointF ptPosition READ pos WRITE setPos FINAL)
|
Q_PROPERTY(QPointF ptPosition READ pos WRITE setPos FINAL)
|
||||||
Q_PROPERTY(QFont textFont READ textFont WRITE setTextFont)
|
Q_PROPERTY(QFont textFont READ textFont WRITE setTextFont)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue