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 top is smaller than bottom why ?
Forum Update on Monday, May 27th 2025

QRect top is smaller than bottom why ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.0k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I am makign a QRect with following

    QRectF rect = QRectF(left, top, width, height);
    int left = rect.left();
    int bottom = rect.bottom();
    int right = rect.right();
    int top = rect.top();

    In this top is < bottom . Why such behavior ?

    joeQJ jsulmJ 4 Replies Last reply
    0
    • Q Qt Enthusiast

      I am makign a QRect with following

      QRectF rect = QRectF(left, top, width, height);
      int left = rect.left();
      int bottom = rect.bottom();
      int right = rect.right();
      int top = rect.top();

      In this top is < bottom . Why such behavior ?

      joeQJ Offline
      joeQJ Offline
      joeQ
      wrote on last edited by
      #2

      @Qt-Enthusiast Hi, friend, did you check the value of left, top, width, height before QRectF(left,top,width,height) ?

      Just do it!

      1 Reply Last reply
      0
      • Q Qt Enthusiast

        I am makign a QRect with following

        QRectF rect = QRectF(left, top, width, height);
        int left = rect.left();
        int bottom = rect.bottom();
        int right = rect.right();
        int top = rect.top();

        In this top is < bottom . Why such behavior ?

        joeQJ Offline
        joeQJ Offline
        joeQ
        wrote on last edited by
        #3

        @Qt-Enthusiast and, You used QRectF means float value. but,

        qreal left = rect.left();  ///< return qreal
        /** ... */
        

        Just do it!

        1 Reply Last reply
        2
        • Q Qt Enthusiast

          I am makign a QRect with following

          QRectF rect = QRectF(left, top, width, height);
          int left = rect.left();
          int bottom = rect.bottom();
          int right = rect.right();
          int top = rect.top();

          In this top is < bottom . Why such behavior ?

          joeQJ Offline
          joeQJ Offline
          joeQ
          wrote on last edited by
          #4

          @Qt-Enthusiast

          QRectF(qreal x, qreal y, qreal width, qreal height)
          qreal	bottom() const
          
          /** ... */
          qreal x,y,w,h;
          x = y = 0.0;
          w = h = 10.0;
          QRectF fRect = QRectF(x,y,w,h);
          qDebug() << fRect;
          /** ... */
          

          Try it to see the value;

          Just do it!

          1 Reply Last reply
          0
          • Q Qt Enthusiast

            I am makign a QRect with following

            QRectF rect = QRectF(left, top, width, height);
            int left = rect.left();
            int bottom = rect.bottom();
            int right = rect.right();
            int top = rect.top();

            In this top is < bottom . Why such behavior ?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #5

            @Qt-Enthusiast "Why such behavior ?" - because the coordinate system works this way. The top left corner is (0, 0), the bottom right corner is (max width - 1, max height - 1).
            See http://doc.qt.io/qt-5.9/coordsys.html

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2

            • Login

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