Hi all,
I’m trying to extend qml by a custom type defined in C++. My type – called SvgItem – is supposed to be able to render a single element of a svg file (by elementId, like QGraphicsSvgItem).
I got it working in-so-far, that the elements are painted in qml. Unfortunately, qml seems to be unable to access size information of my custom type. Therefore, I cannot put my SvgItem in a grid properly or make out its center.
I implemented SvgItem by inheriting QDeclarativeItem and delegating to a QGraphicsSvgItem in painting functions. The QGraphicsSvgItem is held as a member in SvgItem.
I declared the Q_PROPERTYs source and elementId in order to access the svg file and its elements, which apperently works.
However, my SvgItem has no size in qml.
I found a similar implementation in the KDE project: SvgItem.h [lxr.kde.org]
It makes use of the properties implicitWidth and implicitHeight. I implemented them in my SvgItem, but it was no help.
What is the correct way to go, in order to impart the size information to qml?
Thanks a lot!
↧