07-31-2012 07:53 PM
I'm seeing an embarassingly large number of QML samples that all hard-code "768" and/or "1280" for container sizing, to make things correctly fill the screen. As we all know, this is a VERY BAD practice to actually follow in UI markup. Were this BB Java, I'd be using "Display.getWidth()" and "Display.getHeight()" in the code for most of those cases.
So what's the best way to specify, in a QML file (that hopefully won't break the QML preview window), the width or height of the screen?
(Or do we have to hard code it within some properties, that we reset from the C++ that loads the QML?)
07-31-2012 11:03 PM
This is actually a very good question. I have been trying to keep my layouts as dynamic as possible, but some things must be hard coded ![]()
I think that the initial BB hardware will be the same resolution as the dev alpha, so you'll be OK for launch, but soon thereafter the hardware will start to heature different screen resolutions.
Im posting so i can subscribe to the thread ![]()
07-31-2012 11:06 PM
08-07-2012 11:17 AM
I assume you've seen http://supportforums.blackberry.com/t5/Cascades-De
Did you find a way to do this directly from QML, or an easy way to streamline it?
If so, please reply here so all can see.
If not, perhaps you want to create a feature request. Follow instructions in http://supportforums.blackberry.com/t5/Java-Develo
Stuart
08-15-2012 11:52 AM
Please vote for https://www.blackberry.com/jira/browse/BBTEN-172
From C++ you can now more easily find the device size:
#include <bb/device/Display>
...
bb::device:
isplay display;
qDebug() << "Display size: " << display.pixelSize();
Stuart
08-15-2012 12:42 PM
Voted!
08-15-2012 01:52 PM
One concern that may not be completely obvious at first glance is that BB10 supports multiple displays for the device, so a solution to this would need to somehow be specific to "the display that the current page is being shown on". But really, not just that, also the displayable area on that display (which can be affected by the presence of a tab/navigation/action bar and the visibility of the virtual keyboard).
10-02-2012 07:22 PM
Hi guys, appologies if this has been answered elsewhere, or if there is another better solution for this. The solution I'm using is to get DisplayInfo via C++, grab the screen dimensions from that, and pass them in to my QML document. Here's how to do that:
C++ Code:
#include <bb/device/DisplayInfo> using namespace bb::device;
QmlDocument *qml = QmlDocument::create("asset:///main.qml");
qml->setParent(this);
DisplayInfo display;
int width = display.pixelSize().width();
int height = display.pixelSize().height();
QDeclarativePropertyMap* displayProperties = new QDeclarativePropertyMap;
displayProperties->insert("width", QVariant(width));
displayProperties->insert("height", QVariant(height));
qml->setContextProperty("DisplayInfo", displayProperties);Now a DisplayInfo object is accessible from QML like so:
ImageView{
imageSource: "asset:///images/my_awesome_full_screen_image.png"
preferredHeight: DisplayInfo.height
preferredWidth: DisplayInfo.width
scalingMethod: ScalingMethod.AspectFill
}
10-03-2012 08:46 AM
I am pretty sure at BBJAM last week that they said launch devices will go out with a width of 720 px, not 768 px... So the alpha devices are not a perfect match... Here's a post on the blog that links to another site that discusses this:
http://devblog.blackberry.com/2012/09/the-story-be
10-03-2012 08:49 AM