PDA

View Full Version : Storing property lists for custom designer plugins



ghorwin
12th April 2007, 21:07
Hi there,

I have a class with a list of objects. The objects can be edited in my designer plugin. For instance, a list with integer values:
QList<int> m_intlist;

Now I declare this list as a property:



Q_PROPERTY(QList<int> intList READ intList WRITE setIntList DESIGNABLE true)


But even if I change the properties at design time, the values get never stored in the ui file. Does anyone know a solution to this?

Also, I have more complex data types of form QList<SomeClass> and also want to store this data in the ui file? Do I have to overload some xml generating functions or how does the designer know how to convert the object data into proper XML code for the ui file?

Bye

high_flyer
13th April 2007, 10:03
Would you mind explainig how do you edit a list through designer property editor?
I mean, I can see how you can asign a value to one member of the list, but how do you asign several values to the same list?

wysota
13th April 2007, 11:05
Have you tried adding a "STORED true" statement to the property declaration?

ghorwin
13th April 2007, 18:09
high_flyer: I created a custom designer widget extension that opens a dialog where I can edit my property lists

wysota: yes, tried that. Doesn't make a difference. Seems that Qt Designer simply ignores properties that do not have a default editor mode (for the property list) assigned - or worded differently, designer ignores properties it cannot handle.

Now, I would like to append my own customized XML code the code that designer creates when saving a widget. But I cannot find any function in QObject that I could overload for that purpose or otherwise add that additional XML information.

Any idea?

PS: The best solution I have so far is to write the data into an XML document and store this as a plain string property... but this looks really messy in the ui file and can probably be considered a "hack"...

wysota
13th April 2007, 22:52
Try changing QList<int> into QVariantList, there is a high chance Qt will handle the rest.

ghorwin
13th April 2007, 23:32
Nope, doesn't work :-(
Data in QVariantList is also not written to the ui file...

Does anyone know how Qt handles the ui writing internally? Is it taking the information from the metadata? If so, is there any way to overload a function of the metaobject?

wysota
14th April 2007, 08:59
Does your extension mark the property as changed in the property sheet? Maybe the problem is not in writing the property but in that the Designer doesn't know it has to store it... You can verify that by changing the list type again to QStringList as the UI saver handles that nicely. If it doesn't work then it means the problem is elsewhere.