PDA

View Full Version : Get QObject from pointer address



escobar
29th March 2016, 10:55
Probably I coded some invalid styleSheets in my project but now it is so big that is impossible to finde where.

The console throws this:

"Warning: Could not parse stylesheet of object 0xdb8858010 ((null):0, (null))"

I tried to create a widget where I type the address 0xdb8858010 and my wish is to get its name so I did:


void mProj::getWidgetName()
{
bool readedok;
qlonglong mempos = lnGetWidget->text().toLongLong(&readedok, 16);
QString text;
if (readedok)
{
text="Pos: "+QString::number(mempos)+" ";
QObject* qo =mempos;

QWidget* qw = reinterpret_cast<QWidget*>(qo);
if (qw)
text += " name " + qw->objectName();
else
text += " cannot found qobject";
}
else
{
text="Cannot be read";
}
lbGetWidget->setText(text);
}

But I get a crash.


Any thought about this?

Thanks in advance.

anda_skoa
29th March 2016, 11:30
You could use GammaRay (https://www.kdab.com/gammaray/) or put a break point into qWarning() and check the stack trace.

Cheers,
_

Lesiok
29th March 2016, 11:31
How is lnGetWidget initialized ?