Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android wrong size for QDoubleSpinBox and QPushButton (newbe question)
Forum Updated to NodeBB v4.3 + New Features

Android wrong size for QDoubleSpinBox and QPushButton (newbe question)

Scheduled Pinned Locked Moved Mobile and Embedded
resolution cont
3 Posts 3 Posters 1.3k Views 2 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.
  • M Offline
    M Offline
    mbergmann-sh
    wrote on last edited by
    #1

    Hi there :)
    Beeing new to Qt Android programming (...not to Qt!) I ran into problems with the size of Spinboxes and Buttons in my multi-plattform app (written in C++ using Qt 5.4 under linux). What looks good as a desktop app fails to show up in reasonable size, when beeing published on my Samsung Galaxy S5mini cell phone and my Samsung Galaxy tablet (both with Android 4.4).
    Both Spinboxes and Buttons show up too small. Besides that, no Buttons are shown in my custom MessageBoxes when running the app on Android.

    My project uses a QMainWindow, provided with layouts.

    I guess I'd have to write some kind of "android scaling startup code" , but I just don't know where to start. Could someone please provide me some help?

    Thanks for any hints!

    Michael

    p3c0P 1 Reply Last reply
    0
    • metaDomM Offline
      metaDomM Offline
      metaDom
      wrote on last edited by p3c0
      #2

      Hey, the best is to set your sizes by knowing the display size.

      I use the following code for all mobile platforms:

      screen = QGuiApplication::screens().first();
      connect(screen, SIGNAL(virtualGeometryChanged(QRect)), this, SLOT(getScreen()));
      
      void MainWindow::getScreen()
      {
          QRect rec = QApplication::desktop()->screenGeometry();
          screenY = rec.height();
          screenX = rec.width();
      }
      

      "screen" is a QScreen.

      Once you know the x and y coordinates, you can start setting sizes :) Try and error for good results.

      From my experience, a good size for icons (at least for my apps) is calculated this way:

      pushButton->setIconSize(QSize(screenX/15,screenY/15));
      

      For text, the best is to set a font: (20 looks good on 720p and 1080p)

      QFont font = pushButton->font();
      font.setPointSize(20);
      pushButton->setFont(font);
      

      Best regards,

      • Dom
      1 Reply Last reply
      0
      • M mbergmann-sh

        Hi there :)
        Beeing new to Qt Android programming (...not to Qt!) I ran into problems with the size of Spinboxes and Buttons in my multi-plattform app (written in C++ using Qt 5.4 under linux). What looks good as a desktop app fails to show up in reasonable size, when beeing published on my Samsung Galaxy S5mini cell phone and my Samsung Galaxy tablet (both with Android 4.4).
        Both Spinboxes and Buttons show up too small. Besides that, no Buttons are shown in my custom MessageBoxes when running the app on Android.

        My project uses a QMainWindow, provided with layouts.

        I guess I'd have to write some kind of "android scaling startup code" , but I just don't know where to start. Could someone please provide me some help?

        Thanks for any hints!

        Michael

        p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        @mbergmann-sh Check out this doc.

        157

        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