Unsolved QRect top is smaller than bottom why ?
-
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 ?
-
@Qt-Enthusiast Hi, friend, did you check the value of left, top, width, height before
QRectF(left,top,width,height)
? -
@Qt-Enthusiast and, You used
QRectF
meansfloat
value. but,qreal left = rect.left(); ///< return qreal /** ... */
-
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;
-
@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