[Interest] Unexplained offset in QML

Jason H scorp1us at yahoo.com
Fri Jan 3 23:08:39 CET 2014


I have a QML object that is several Images. When I load the whole thing, I do it as a two-step process. The first is a static QML file that properly nests the objects. That is inherited by one that sets the source and location of the images.

The images are correct, with no white space. The offsets are correct. But when displayed, it is horizontally offset. The width is properly calculated.

Some code is below:


Animal {
function objName() { return 'puppy1';}
id: puppy1
Rectangle { anchors.fill: parent; opacity: 0.2; color: "purple"; border.width: 1}
Rectangle { x:0; y:0; width: 10; height:10; opacity: 0.5; color: "red"; border.width: 1}
Component.onCompleted: {
tail.source = objName() + '/tail.png';
tail.x=35.94994652;
tail.y=228.608;

earL.source = objName() + '/ear-l.png';
earL.x=218.11224652;
earL.y=9.721;

earR.source = objName() + '/ear-r.png';
earR.x=0.0;
earR.y=9.721;

Now, what happens here is the purple rectangle is the proper size and location. Same for the red rectangle, but all the image objects are too far to the right (tail, earL and earR). Even though the purple rect's anchors are fill parent (the puppy1) the images extend past the purple box. This should not be possible. EarR.x is set to 0.0, so it should be on the left edge, but it isn't.

I have no idea hoe to explain or fix this. Ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140103/5dfca51c/attachment.html>


More information about the Interest mailing list