-
Hello,
sorry for this 2 stupid questions, i could not find information on this by my self.QObject * obj; obj = new QObject(); qDebug() << "obj : " << obj; qDebug() << "obj adr : " << &obj; //output //obj : QObject(0x2532b60) //obj adr : 0x65fd48
what is the 0x2532b60 ? i always tought it is the object adress.
second question is : If i look at qdebug operator << https://doc.qt.io/qt-5/qdebug.html#public-functions
i don't understand witch one is used when i call,qDebug() << obj;
is it the last one "operator<<(const void *t)" ?
Thank you -
@LeLev said in object adress:
what is the 0x2532b60 ? i always tought it is the object adress.
&obj
since obj is a pointer, you see the address of the pointer
-
@LeLev said in object adress:
what is the 0x2532b60 ? i always tought it is the object adress.
0x2532b60 is the address of QObject, which is allocated in heap by operator
new
.0x65fd48 is the address of
obj
variable of typeQObject*
, which is allocated on stack and holds address ofQObject
object.second question is : If i look at qdebug operator << https://doc.qt.io/qt-5/qdebug.html#public-functions
i don't understand witch one is used when i call,qDebug() << obj;
is it the last one "operator<<(const void *t)" ?
No, it's
QDebug operator<<(QDebug, const QObject *)
. Overload forvoid*
pointers prints just value without "QObject(...)" wrapping -
@Christian-Ehrlicher, @Konstantin-Tokarev
thank you very much for your inputs.