Solved How to detect "user interface idiom" of a screen?
-
On some OSes, you can differentiate how a screen is being used based on an "idiom", which is to say one of:
- phone
- tablet
- laptop/desktop
For instance, the iPhone has the idiom UIUserInterfaceIdiomPhone and the iPad has UIUserInterfaceIdiomPad.
I believe Android has equivalent concepts.
In the case of the PinePhone Linux phone, it can use the main phone screen as a phone user interface, and a connected HDMI monitor as a desktop GUI.How in Qt can I programmatically learn which UI idiom is being used on a given screen?
-
Hi,
That's a good question. You should contact the Pine Phone folks to see if they have implemented something particular for that.
Did you check QScreen::name ?
-
@SGaist Grepping through the Qt5 header files I don't see any mention of the idea
of a phone UI versus a desktop UI.
Does Qt6 have such a differentiation?I'm waiting for someone who has a pinephone to let me know.
I see that for my monitor the name is HDMI-1, the same as what the xrandr program reports. -
@Publicnamer said in How to detect "user interface idiom" of a screen?:
@SGaist Grepping through the Qt5 header files I don't see any mention of the idea
of a phone UI versus a desktop UI.
Does Qt6 have such a differentiation?No. Qt is cross-platform, it treats every device and screen the same. Check screen dimensions and pixel density to decide which UI to show.
At compile time, you do have some OS defines, like
Q_OS_LINUX
,Q_OS_ANDROID
etc. -
You could first detect if the OS is Linux and then call some Linux-specific code to detect the release/Linux-flavor (e.g., check what's in '/etc/os-release'). If you find it's a PinePhone, then assume screen 0 is the phone's built-in display and everything else an external display.
-
@mchinand said in How to detect "user interface idiom" of a screen?:
then call some Linux-specific code to detect the release/Linux-flavor (e.g., check what's in '/etc/os-release').
No need, you can use QSysInfo for that.
-
@sierdzio I've learned that the pinephone's screen 0 is called DSI-1. I assume it's named after Display Serial Interface.