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. How to get Window width/height
QtWS25 Last Chance

How to get Window width/height

Scheduled Pinned Locked Moved QML and Qt Quick
qmlwindow
4 Posts 2 Posters 2.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.
  • lajtuL Offline
    lajtuL Offline
    lajtu
    wrote on last edited by
    #1

    I'm trying to get Window width by calling:

    • Window.width

    However it returns "undefined". It's the same for other Window properties:

    • Window.height
    • Window.x
    • Window.maximumWidth

    I tried to use it instead of calling some root Item:

    • itemId.width

    because in some Screen.onHeightChanged callback it returns 0.

    Why is it undefined ? Do I make something wrong ?

    p3c0P 1 Reply Last reply
    0
    • lajtuL lajtu

      I'm trying to get Window width by calling:

      • Window.width

      However it returns "undefined". It's the same for other Window properties:

      • Window.height
      • Window.x
      • Window.maximumWidth

      I tried to use it instead of calling some root Item:

      • itemId.width

      because in some Screen.onHeightChanged callback it returns 0.

      Why is it undefined ? Do I make something wrong ?

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

      Hi @lajtu,
      Since those are not attached properties they will need to be accessed by id i.e Window's id.

      157

      1 Reply Last reply
      0
      • lajtuL Offline
        lajtuL Offline
        lajtu
        wrote on last edited by
        #3

        Aww, OK. I thought it works the same as Screen, e.g.

        • Screen.width
        p3c0P 1 Reply Last reply
        0
        • lajtuL lajtu

          Aww, OK. I thought it works the same as Screen, e.g.

          • Screen.width
          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @lajtu For Screen it works because width is an Attached Property for it.

          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