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.
  • L Offline
    L Offline
    lajtu
    wrote on 28 Jun 2015, 15:53 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 ?

    P 1 Reply Last reply 29 Jun 2015, 06:30
    0
    • L lajtu
      28 Jun 2015, 15:53

      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 ?

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 29 Jun 2015, 06:30 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
      • L Offline
        L Offline
        lajtu
        wrote on 29 Jun 2015, 07:42 last edited by
        #3

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

        • Screen.width
        P 1 Reply Last reply 29 Jun 2015, 07:45
        0
        • L lajtu
          29 Jun 2015, 07:42

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

          • Screen.width
          P Offline
          P Offline
          p3c0
          Moderators
          wrote on 29 Jun 2015, 07:45 last edited by
          #4

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

          157

          1 Reply Last reply
          0

          2/4

          29 Jun 2015, 06:30

          • Login

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