Drawing with units like mm instead of pixels
-
Hi,
We'd like to do all our UI stuff in physical units rather than pixels. For this I implemented one of the solutions referred to by this bug report:
http://bugreports.qt.nokia.com/browse/QTBUG-11655
So if I want to use mm instead of pixels I simply write:
@
Image {
width: 45mm
height: 45mm
source: "gfx/random.svg"
}
@And the mm is a property defined from C++ like this:
@
rootContext->setContextProperty( "mm", viewer.physicalDpiX()/25.4 );
@This works just fine. But the problem occurs when I try to use a BorderImage. The borders are read only and when using this technique it tries to write the result of the multiplication to a read only value. See this example:
@
BorderImage {
source: "gfx/random_border_image.svg"
width: 22mm
height: 22mm
border: { left: 3mm; top: 2mm; right: 3.5mm; bottom: 3mm; }
}
@This gives me the error: "Invalid property assignment: "border" is a read-only property".
Unfortunately I have not found a way to get around this and still use physical units for our BorderImage's.
Any ideas?
-
I think it's in interesting concept using physical units with border images, but I'm not sure how that is supposed to work.
The whole nature of a border image is very pixel-centric to begin with. It seems as though you generally want to split a border image on rigidly-fixed positions of the source image. Otherwise you might have some overshooting (or undershooting) boundaries on the image itself depending on the dpi of the display.
What's your source image like in that sort of scenario?
-
@mario, @mlong: let me get back to you when I have more experience with BorderImages together with svg and physical units. But as long as the BorderImage behaves it should just work using mm instead of pixels. Since we are using svgs things are scaled nicely.
Right now I'm just using Image instances showing svgs with physical units. And that does indeed work very well. At least on the Symbian platforms. 1*mm gets you 1 mm on the physical devices (tested on an N8 and E7 which have a large resolution difference).