Results 1 to 6 of 6

Thread: focusChanged() getting qwidget type

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: focusChanged() getting qwidget type

    If you use qobject_cast, there is really no point in comparing class names yourself using QMetaObject::className(). Just make the cast and see if resulting pointer is null or not. And remember meta-object for a class is only generated if the class contains the Q_OBJECT macro.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Mar 2009
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: focusChanged() getting qwidget type

    Quote Originally Posted by wysota View Post
    If you use qobject_cast, there is really no point in comparing class names yourself using QMetaObject::className(). Just make the cast and see if resulting pointer is null or not. And remember meta-object for a class is only generated if the class contains the Q_OBJECT macro.
    Awesome! I actually did it this way. Just casted it and if it wasnt null did what i wanted and it works correctly! thanks for your help! Yeah ive gotten the classes written correctly ive seen people forget to include the Q_OBJECT line a lot.

Similar Threads

  1. Convert between a custom data type wrapped in a QVariant
    By darkadept in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 09:07
  2. Replies: 0
    Last Post: 11th November 2008, 15:36
  3. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  4. QWidget and type
    By nowire75 in forum Newbie
    Replies: 1
    Last Post: 8th November 2007, 19:55
  5. dummy question(Error)
    By Masih in forum Qt Programming
    Replies: 12
    Last Post: 19th July 2007, 23:38

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
  •  
Qt is a trademark of The Qt Company.