Discussion:
How to distinguish from iPhone screen type with Qt/Qml
(too old to reply)
Nuno Santos
2018-12-03 12:34:36 UTC
Permalink
Hi,

I’m trying to make my iOS apps ready for iPhone X screen as well as the new iPads.

How can I distinguish the screen types? Can I do that directly from Qml? How?

Thanks in advance!

Regards,

Nuno
ekke
2018-12-03 12:47:49 UTC
Permalink
Hi Nuno,
one way is to detect from pixels

perhaps this gives you an idea:
https://github.com/ekke/c2gQtWS_x/blob/master/cpp/unsafearea.cpp

later will use mobile device types to better distinguish between
different models
best overview I found here: https://gist.github.com/adamawolf/3048717

ekke
Post by Nuno Santos
Hi,
I’m trying to make my iOS apps ready for iPhone X screen as well as the new iPads.
How can I distinguish the screen types? Can I do that directly from Qml? How?
Thanks in advance!
Regards,
Nuno
_______________________________________________
Interest mailing list
https://lists.qt-project.org/listinfo/interest
maitai
2018-12-03 13:02:52 UTC
Permalink
Hi,
Here I call an objective C function at startup, which stores a global
boolean var

if ( [(NSString*)[UIDevice currentDevice].model hasPrefix:@"iPad"] )
isIphone = false;
else
isIphone = true;

Philippe.
Post by ekke
Hi Nuno,
one way is to detect from pixels
https://github.com/ekke/c2gQtWS_x/blob/master/cpp/unsafearea.cpp
later will use mobile device types to better distinguish between
different models
best overview I found here: https://gist.github.com/adamawolf/3048717
ekke
Post by Nuno Santos
Hi,
I’m trying to make my iOS apps ready for iPhone X screen as well as the new iPads.
How can I distinguish the screen types? Can I do that directly from Qml? How?
Thanks in advance!
Regards,
Nuno
_______________________________________________
Interest mailing list
https://lists.qt-project.org/listinfo/interest
_______________________________________________
Interest mailing list
https://lists.qt-project.org/listinfo/interest
Jason H
2018-12-03 14:48:43 UTC
Permalink
I write ALL my mobile apps in terms of display percentage. The Notch issue is particularly annoying because it behaves as if it doesn't exist, so you have to make a space reservation for it. It would help if the Qt QML global gave you the model, like Qt.platform.model so you could activate a top margin with a property binding. Ce'est la vie. You have to call a native platform function to do that...
Sent: Monday, December 03, 2018 at 7:47 AM
Subject: Re: [Interest] How to distinguish from iPhone screen type with Qt/Qml
Hi Nuno,
one way is to detect from pixels
https://github.com/ekke/c2gQtWS_x/blob/master/cpp/unsafearea.cpp
later will use mobile device types to better distinguish between
different models
best overview I found here: https://gist.github.com/adamawolf/3048717
ekke
Post by Nuno Santos
Hi,
I’m trying to make my iOS apps ready for iPhone X screen as well as the new iPads.
How can I distinguish the screen types? Can I do that directly from Qml? How?
Thanks in advance!
Regards,
Nuno
_______________________________________________
Interest mailing list
https://lists.qt-project.org/listinfo/interest
_______________________________________________
Interest mailing list
https://lists.qt-project.org/listinfo/interest
Nuno Santos
2018-12-06 23:39:18 UTC
Permalink
Hi,

Thank you all for sharing your approaches.

I found one approached shared at the end of the following bug report, by David Hess (which requires linking to gui-private) that seemed to me very simple but it is not fully working in my case.

https://bugreports.qt.io/browse/QTBUG-64574 <https://bugreports.qt.io/browse/QTBUG-64574>

By the way, on initial email subject there was a X missing! Sorry for that! :)

Best regards,

Nuno
Post by ekke
Hi Nuno,
one way is to detect from pixels
https://github.com/ekke/c2gQtWS_x/blob/master/cpp/unsafearea.cpp
later will use mobile device types to better distinguish between
different models
best overview I found here: https://gist.github.com/adamawolf/3048717
ekke
Hi,
I’m trying to make my iOS apps ready for iPhone X screen as well as the new iPads.
How can I distinguish the screen types? Can I do that directly from Qml? How?
Thanks in advance!
Regards,
Nuno
_______________________________________________
Interest mailing list
https://lists.qt-project.org/listinfo/interest
_______________________________________________
Interest mailing list
https://lists.qt-project.org/listinfo/interest
Jérôme Godbout
2018-12-03 14:28:03 UTC
Permalink
You can take a look at Qt.application.screens and detect by resolution along with Qt.platforms should be doable but I think the http://doc.qt.io/qt-5/qsysinfo.html QSysInfo will give you a better check and you can expose this to a property or Q_INVOKABLE function. It doesn't seem to have anything to display the phone model. So you can do an .mm obj-c call:
[[UIDevice currentDevice] platformString]
Should do the trick.
Put this into a QString return value function QString::fromNString() and you should be good to go. You might need to stub this on other platform.

-----Original Message-----
From: Interest <interest-***@lists.qt-project.org> On Behalf Of Nuno Santos
Sent: December 3, 2018 7:35 AM
To: ***@qt-project.org Interest <***@qt-project.org>
Subject: [Interest] How to distinguish from iPhone screen type with Qt/Qml

Hi,

I’m trying to make my iOS apps ready for iPhone X screen as well as the new iPads.

How can I distinguish the screen types? Can I do that directly from Qml? How?

Thanks in advance!

Regards,

Nuno
_______________________________________________
Interest mailing list
***@lists.qt-project.org
https://lists.qt-project.org/listinfo/interest
Continue reading on narkive:
Loading...