I am just curious. Let's say for example I need to output a number in the console.
The code would be:
#include <QDebug>
#include <QVariant>
#include <QString>
void displayNumber(quint8 number) {
qDebug() << QVariant(number).toString();
qDebug() << QString::number(number);
//or for example
// QLabel label;
// label.setText(QString::number(number));
//or
// label.setText(QVariant(number).toString());
}
Which would be better performance wise? I think the memory consumption is also different. QVariant(number).toString() would mean that it stores a QVariant in the stack. Not sure about QString::number(), shouldn't it just call the function(sure, the function has a QString return so it is allocated on the stack too and takes that space and that operations to allocated and unallocate it)? Anyway, sizeof() gives me 16 Bytes for QVariant and 4 Bytes for QString.