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. [RFC] Using DP instead of PX for Android
Forum Updated to NodeBB v4.3 + New Features

[RFC] Using DP instead of PX for Android

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 2.6k Views 1 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.
  • B Offline
    B Offline
    benlau
    Qt Champions 2016
    wrote on 25 Nov 2013, 15:21 last edited by
    #1

    Density-independent pixel (dp) is a virtual pixel unit used in the Android platform. It helps to express layout dimensions or position in a density-independent way. The Android style guide uses DP as the metrics of UI component. Reference : http://developer.android.com/design/style/metrics-grids.html

    However, I cannot find any method to use DP on QML provided by the SDK. Therefore, I have written my own solution and wish it can also help others to speed up Android development. As now it is just the first draft, it is not perfect. Therefore, I would like to seek for comment from everybody to help to improve it. So please feel free to suggest any better solution. Thanks.

    "Example Code":https://github.com/benlau/junkcode/tree/master/qt/androidmetricdemo

    Design and issue

    1. The conversion from DP to PX is not using the method suggested by QTBUG-11655.

    Reason: Passing the unit from context object will break the Qt Designer.

    https://bugreports.qt-project.org/browse/QTBUG-11655

    1. A splash QML is needed.

    Unlike the method suggested in #11655 , the conversion is done by a function with static parameter. The parameter must be set before the main scene. That is why it need a splash scene to prepare the parameter.

    1 Reply Last reply
    0

    1/1

    25 Nov 2013, 15:21

    • Login

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