Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Solved QML Window.with in android

    Mobile and Embedded
    2
    2
    226
    Loading More Posts
    • 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
      msauer75 last edited by

      Hello,

      in my qml application I use window.with to determine the window resolution. On my linux pc I will get the correct value, but on an android device I will get 0 for width.
      Do you know how can I get the window resolution in qml?

      Thank you for your help
      BR
      martin

      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @msauer75 last edited by

        hi @msauer75

        Screen should help you

        import QtQuick.Window 2.13
        ...
        ...
        Component.onCompleted:{
             console.log(Screen.desktopAvailableHeight, Screen.desktopAvailableWidth, Screen.devicePixelRatio, Screen.pixelDensity)
        }
        

        Reference:
        https://doc.qt.io/qt-5/qml-qtquick-window-screen.html

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply Reply Quote 1
        • First post
          Last post