[Qt-qml] Can you shadow / override elements
michael.brasser at nokia.com
michael.brasser at nokia.com
Mon Nov 1 08:01:54 CET 2010
Hi,
On 29/10/2010, at 11:11 PM, ext henrik.hartz at nokia.com<mailto:henrik.hartz at nokia.com> wrote:
in Qt Quick components we need to reuse a few elements from QML - but make them styled to fit the platform theme. E.g. the Label element is-a Text element, except we apply font, sizing, colors, margins etc from the theme. It would be silly from the end-user perspective to have to relate to multiple element names for the same functionality. is there a way to do e.g.
Text.qml;
import QtQuick 1.0
Text {
font.family: style.get("fontfamily")
... etc
}
basically allowing eforcing some property default values, while still keeping the same API and element name?
See e.g. Label from http://bugreports.qt.nokia.com/browse/QTCOMPONENTS-200 for reference
In this case I think giving the component it's own name (or adding a Text in e.g. QtComponents namespace) would be better than trying to override Text from the QtQuick namespace. My main concern is that styling at this layer will make non-styled components/applications harder -- it feels like styling belongs at a higher "layer" in the QML stack. For example, right now I can add a Text element to an Image element to make a button, and be relatively confident of identical results cross-platform -- the only differences should be in default font family and point size. If Text could strongly vary depending on the platform, that would become more difficult.
Regards,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20101101/a19b2355/attachment.html
More information about the Qt-qml
mailing list