Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. What's wrong with screen size and parent's size on Android
Forum Updated to NodeBB v4.3 + New Features

What's wrong with screen size and parent's size on Android

Scheduled Pinned Locked Moved QML and Qt Quick
qmlandroid
3 Posts 2 Posters 1.1k 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.
  • sosunS Offline
    sosunS Offline
    sosun
    wrote on last edited by
    #1

    Hello, Guys! I can't understand why does a one snippet work properly and other doesn't when they're absolutely similar speaking of logic IMO.

    ApplicationWindow {
        id: root
        title: "My 1st QML App"
        width: 480
        height: 640
        visible: true
         
          Rectangle {
              id: rectangle
              anchors.centerIn: parent
              width: parent.width
              height: parent.height   
              color: "#9B76CC"
          }
    }
    

    Here ApplicationWindow is our parent, so this because width: 480 and height: 640. As result, I'm getting a color-filled, full-screened rectangle on my smartphone's screen. And I'm expecting the same result as if I had set width: 480 and height: 640 without using parent keyword. In both situations, we have the same sizes, but it appears that in the latter case we get small, i.e. not full-screened, rectangle on my nexus5's screen. What's the problem?

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xargs1
      wrote on last edited by
      #2

      Your Nexus 5's screen is not 480x640. I don't know anything about Qt on Android, but my guess would be that an ApplicationWindow on Android fills the screen (which is actually 1920x1080) regardless of its width and height settings, thus parent.width is not what you think it is in your Rectangle.

      1 Reply Last reply
      1
      • sosunS Offline
        sosunS Offline
        sosun
        wrote on last edited by
        #3

        Yeah, you're correct. So the bottom line is that ApplicationWindow fills whole screen by default. I think so. Unfortunately, I can't prove it, i.e. desribe whole process with facts and links to documentation, but I tried different ways w/w/o ApplicationWindow and tricks with proportions and your guess was correct. Thanks!

        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