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. Screen Size to make portable to all devices.
Forum Update on Monday, May 27th 2025

Screen Size to make portable to all devices.

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.1k Views
  • 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.
  • Pradeep KumarP Offline
    Pradeep KumarP Offline
    Pradeep Kumar
    wrote on last edited by Pradeep Kumar
    #1

    Hi,

    I am using Android, Arm and desktop devices, i want to run the application in all devices, but the screen width and height i dont want to hardcore. i am using Qt to develop the application.

    I used
    QDesktopWidget widget;
    QRect mainScreenSize = widget.availableGeometry(widget.primaryScreen());

     int w =   widget.screen(1)->width();
     int h =  widget.screen(1)->height();
    

    but in android device i am not getting the properly , can u guys guide me to make the application portable in all devices.?.

    Pradeep Kumar
    Qt,QML Developer

    raven-worxR 1 Reply Last reply
    0
    • Pradeep KumarP Pradeep Kumar

      Hi,

      I am using Android, Arm and desktop devices, i want to run the application in all devices, but the screen width and height i dont want to hardcore. i am using Qt to develop the application.

      I used
      QDesktopWidget widget;
      QRect mainScreenSize = widget.availableGeometry(widget.primaryScreen());

       int w =   widget.screen(1)->width();
       int h =  widget.screen(1)->height();
      

      but in android device i am not getting the properly , can u guys guide me to make the application portable in all devices.?.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Pradeep-Kumar
      you should use qApp->primaryScreen() instead the one from QDesktopWidget.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • Pradeep KumarP Offline
        Pradeep KumarP Offline
        Pradeep Kumar
        wrote on last edited by
        #3

        i tried
        qApp->primaryScreen()->availableSize().width()
        qApp->primaryScreen()->availableSize().height()

        to get the width and height. is this the way, to get width and height?.

        Pradeep Kumar
        Qt,QML Developer

        raven-worxR 1 Reply Last reply
        1
        • Pradeep KumarP Pradeep Kumar

          i tried
          qApp->primaryScreen()->availableSize().width()
          qApp->primaryScreen()->availableSize().height()

          to get the width and height. is this the way, to get width and height?.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Pradeep-Kumar
          does it match your phones/emulators screen dimension?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • Pradeep KumarP Offline
            Pradeep KumarP Offline
            Pradeep Kumar
            wrote on last edited by
            #5

            I tried with Android device, when it comes to orientation what will be the scenario , how to handle?.

            Pradeep Kumar
            Qt,QML Developer

            raven-worxR 1 Reply Last reply
            0
            • Pradeep KumarP Pradeep Kumar

              I tried with Android device, when it comes to orientation what will be the scenario , how to handle?.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by raven-worx
              #6

              @Pradeep-Kumar
              in QML there is the Screen.orientation property
              In widgets you would just receive a resize event i think.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0

              • Login

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