[Solved]Functions of the QRectF class
-
Greetings.
I wanted to know if the values returned by the functions:
@
QRectF::topLeft()
QRect::topRight()
QRectF::bottomleft()
QRectF::bottomRight()
@are calculated whenever these functions are invoked or are stored as internal attributes of the QRectF class.
I have doubts about whether it is better to invoke those functions just once and store the returned values (for future reference) or, on the contrary, it is best to invoke these functions whenever needed.
Thanks in advance for any answers and / or suggestions.
-
As Qt is open-source, you can just have a look inside the code for yourself! I did it for you, and in qrect.h, we have:
@
inline QPointF topLeft() const { return QPointF(xp, yp); }
inline QPointF bottomRight() const { return QPointF(xp+w, yp+h); }
inline QPointF topRight() const { return QPointF(xp+w, yp); }
inline QPointF bottomLeft() const { return QPointF(xp, yp+h); }
@
So there shouldn't be a problem...In general: DO NOT WORRY ABOUT PERFORMANCE TOO EARLY. Always measure it. Use profiling, and when you clearly identify a problem, pinpoint the exact spot and take care of the problem.
-
Thanks for the reply and advice