Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why do the corner points of a rectangle have odd coordinates?

Why do the corner points of a rectangle have odd coordinates?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 383 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.
  • S Offline
    S Offline
    Sano
    wrote on last edited by
    #1

    Hello, I noticed some small bug in my code which led me to the following oddity.

    QRect b(0,0,100,100)
    int c = b.topRight().x()
    

    Why is c = 99 and not 100? This doesn't make any sense for me.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Sano said in Why do the corner points of a rectangle have odd coordinates?:

      Why is c = 99 and not 100?

      Because it's made for displaying rects on the screen - see also https://lists.qt-project.org/pipermail/development/2022-April/042379.html

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3
        QRect b(0,0,100,100); // a rectangle at (0,0) that is 100 by 100 units in size.
        

        In your rectangle:

        • There are 100 columns from left-to-right numbered from 0 to 99.
        • There are 100 rows from top-to-bottom numbered from 0 to 99.
        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