Results 1 to 3 of 3

Thread: Get QObject from pointer address

  1. #1
    Join Date
    Sep 2013
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Get QObject from pointer address

    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:

    Qt Code:
    1. void mProj::getWidgetName()
    2. {
    3. bool readedok;
    4. qlonglong mempos = lnGetWidget->text().toLongLong(&readedok, 16);
    5. QString text;
    6. if (readedok)
    7. {
    8. text="Pos: "+QString::number(mempos)+" ";
    9. QObject* qo =mempos;
    10.  
    11. QWidget* qw = reinterpret_cast<QWidget*>(qo);
    12. if (qw)
    13. text += " name " + qw->objectName();
    14. else
    15. text += " cannot found qobject";
    16. }
    17. else
    18. {
    19. text="Cannot be read";
    20. }
    21. lbGetWidget->setText(text);
    22. }
    To copy to clipboard, switch view to plain text mode 

    But I get a crash.


    Any thought about this?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get QObject from pointer address

    You could use GammaRay or put a break point into qWarning() and check the stack trace.

    Cheers,
    _

  3. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,460
    Thanked 271 Times in 266 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get QObject from pointer address

    How is lnGetWidget initialized ?

Similar Threads

  1. display pointer memory address
    By milosav in forum Qt Programming
    Replies: 8
    Last Post: 2nd February 2016, 08:54
  2. Replies: 2
    Last Post: 18th August 2015, 14:08
  3. Replies: 1
    Last Post: 7th April 2014, 23:44
  4. Output the address of an object i.e. a pointer?
    By Jeffb in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2012, 09:04
  5. How to get a pointer to a QObject's property ?
    By HiJack in forum Qt Programming
    Replies: 7
    Last Post: 28th August 2010, 10:54

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.