| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 2 | |
Hi,
I am designing a property browser, I am facing some problems I hope
some you can help me. I created a composite widget, with four controls,
there is a tree widget in which I display the Properties and their values
for each of the 4 other widgets, based on the one selected. In my code I
am able to get the property names but not the property values.
I am trying this by two ways.
1. I get the QMetaProperty for the wigdet using property, and use the
QMetaProperty' read() to get that specific property' value as a QVariant.
Based on the QVariant's type I try to get the value, but its always empty.
I have placed all the error checks. (This QVariant object is valid and is
of type string (for example), it still returns empty)
2. After I get the property object using QMetaProperty, I get the
property name and use the widget's property function by passing the
property name as a parameter. This returns a QVariant, but when I try to
extract the value I get an empty string, or 0 in the case of ints.
What Should I do. IS there any special initializations for QVariants.
Please advise..
Also is there a way by which I can find out if a certain property is
associated with a QWidget class or its superior class.
With regards,
sitaram.sukumar wrote: > In my code I am able to get the property names > but not the property values. > I am trying this by two ways. > [...] This returns a QVariant, but when I try to extract > the value I get an empty string, or 0 in the case of ints. What are you expecting? Can't it be that the value *is* an empty string, or a 0? If you're getting a valid QVariant, you probably got the "correct" value. Maybe make a minimal compilable example of your problem? > Also is there a way by which I can find out if a certain > property is associated with a QWidget class or its superior class. Use QMetaObject::superClass() and check if that also has the property, until the superclass no longer has it. Then you'll know which superclass it belongs to. Cheers, Peter -- [ signature omitted ]
Em Tuesday 09 October 2007 12:57:14 Peter Prade escreveu: > > Also is there a way by which I can find out if a certain > > property is associated with a QWidget class or its superior class. > > Use QMetaObject::superClass() and check if that also has the property, > until the superclass no longer has it. Then you'll know which superclass > it belongs to. Technically, the super class can have a different property of the same name. You should compare the property index with metaobject->propertyOffset(). If it's less than the offset, the property belongs to a parent class. -- [ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.
Thiago Macieira wrote: > Technically, the super class can have a different property of > the same name. Wow, this sounds sick! Do you know an example where this is the case? What a nightmare when both properties have some effect on your object, and you need to tweak them both. Cheers, Peter -- [ signature omitted ]
On tirsdag den 9. Oktober 2007, Peter Prade wrote: > Thiago Macieira wrote: > > Technically, the super class can have a different property of > > the same name. > > Wow, this sounds sick! Do you know an example where this is the case? > What a nightmare when both properties have some effect on your object, > and you need to tweak them both. I don't think there are any, but that doesn't mean we can't make some. It's just another one of those places where you have to not shoot yourself in the foot. Related to this one is "overriding" non-virtual methods or subclass vars with the same name as base class vars. They're both possible, but in 99.9% of the cases never what you want. Bo. -- [ signature omitted ]