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. QRect and wrong rectangle coordinates
Forum Updated to NodeBB v4.3 + New Features

QRect and wrong rectangle coordinates

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

    Hi,

    Currently using QT 5.15 and reading Qrect, I just want to make sure of one thing:

    QRect a(0,100,50,-50);
    

    yields (for topLeft, topRight, bottomRight, bottomLeft):

    QPoint(0,100)   QPoint(49,100)   QPoint(49,49)   QPoint(0,49)
    

    Which is correct (don't care about the -1)

    But if I do

    QRect a(0,100,50,50);
    

    it yields

    QPoint(0,100)   QPoint(49,100)   QPoint(49,149)   QPoint(0,149)
    

    Which is not logical since the topLeft is below the bottomLeft !
    So to be correct in all cases (rotation included), should I enforce the minus ? Or will another surprise arise?

    Thanks

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      What are you talking about?
      QPoint(0,149) is below QPoint(0,100) because the GUI coordinate system looks like this:
      https://doc.qt.io/qt-5/images/coordinatesystem-rect.png
      (picture is from: https://doc.qt.io/qt-5/coordsys.html)

      1 Reply Last reply
      1
      • J Offline
        J Offline
        JulienD
        wrote on last edited by
        #3

        Missed that info. Everything is alright. thanks!

        1 Reply Last reply
        0
        • HoMaH Offline
          HoMaH Offline
          HoMa
          wrote on last edited by
          #4

          I want to add that the documentation of QRect reads different from your assumption: The consturctor which takes 4 int arguments assums "width" and "height" as last arguments. These are no point coordinates.

          QRect(int x, int y, int width, int height)
          
          1 Reply Last reply
          3

          • Login

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