[Qt-qml] Order of property initialization and assignments

mathias.malmqvist at nokia.com mathias.malmqvist at nokia.com
Tue Nov 2 18:36:18 CET 2010


So apparently the problem is that the default values are taken from the styling element that is loaded dynamically, 
which means they get loaded and set at a point in time after the pixel size has been set in Gallery.qml, overwriting the value we wanted.

Is there any way I can tell if a property has been explicitly assigned a value, and so not assign the default?
Or is there an entirely better way of doing this?


Cheers
Mathias
________________________________________
From: qt-qml-bounces at trolltech.com [qt-qml-bounces at trolltech.com] On Behalf Of Malmqvist Mathias (Nokia-MS/London)
Sent: Tuesday, November 02, 2010 4:58 PM
To: qt-qml at trolltech.com
Subject: [Qt-qml] Order of property initialization and assignments

Hi,

Need some help understanding why my code doesn't work.
See http://qt.gitorious.org/~mathiasm/qt-components/mathiasm-qt-components/blobs/upstream-custom/LineEdit.qml
(apologies if by the time you look at the code the line numbers have changed)

On line 12 I define an alias for the font of the TextInput element defined on line 36. The intention is to allow the user of the LineEdit element to set things like font size and whether the font is bold or italic or not.
On lines 39 and 40 I set some defaults for the fonts pixelSize and boldness. The defaults are fetched from the styling element instantiated on line 18 and defined here
http://qt.gitorious.org/~mathiasm/qt-components/mathiasm-qt-components/blobs/upstream-custom/styles/default/LineEditStyle.qml

On line 48 here
http://qt.gitorious.org/~mathiasm/qt-components/mathiasm-qt-components/blobs/upstream-custom/Gallery.qml
we create a LineEdit instance and set the font to italic and 40 pixels size.

Now running the Gallery.qml file the text show italic, but not in the size we set (but rather the default size). This is probably because we didn't set a default for whether the font is italic or not, but set a default for the pixel size.

So; what's going on? Is this a problem to do with the rules for the order in which properties are initialization and overridden? What are those rules, and can I control them to get the behavior I want?


Cheers
Mathias

_______________________________________________
Qt-qml mailing list
Qt-qml at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml




More information about the Qt-qml mailing list