Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to detect "user interface idiom" of a screen?
Forum Updated to NodeBB v4.3 + New Features

How to detect "user interface idiom" of a screen?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 647 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Publicnamer
    wrote on 13 Oct 2021, 04:36 last edited by Publicnamer
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Oct 2021, 20:08 last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply 14 Oct 2021, 00:18
      0
      • S SGaist
        13 Oct 2021, 20:08

        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 ?

        P Offline
        P Offline
        Publicnamer
        wrote on 14 Oct 2021, 00:18 last edited by
        #3

        @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.

        S 1 Reply Last reply 14 Oct 2021, 05:06
        0
        • P Publicnamer
          14 Oct 2021, 00:18

          @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.

          S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 14 Oct 2021, 05:06 last edited by
          #4

          @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.

          (Z(:^

          1 Reply Last reply
          4
          • M Offline
            M Offline
            mchinand
            wrote on 14 Oct 2021, 13:29 last edited by
            #5

            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.

            S 1 Reply Last reply 14 Oct 2021, 19:35
            0
            • M mchinand
              14 Oct 2021, 13:29

              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.

              S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 14 Oct 2021, 19:35 last edited by
              #6

              @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.

              (Z(:^

              P 1 Reply Last reply 14 Oct 2021, 19:41
              1
              • S sierdzio
                14 Oct 2021, 19:35

                @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.

                P Offline
                P Offline
                Publicnamer
                wrote on 14 Oct 2021, 19:41 last edited by
                #7

                @sierdzio I've learned that the pinephone's screen 0 is called DSI-1. I assume it's named after Display Serial Interface.

                1 Reply Last reply
                0

                1/7

                13 Oct 2021, 04:36

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved