Created
January 16, 2018 07:50
-
-
Save j2doll/74358f7539aa6e68e6922ab5bceb7907 to your computer and use it in GitHub Desktop.
Qt MOC sample #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // class MyWidget : public QWidget | |
| QObject *obj = new MyWidget; | |
| QWidget *widget = qobject_cast<QWidget *>(obj); | |
| Q_ASSERT( widget != NULL ); | |
| MyWidget *myWidget = qobject_cast<MyWidget *>(obj); | |
| Q_ASSERT( myWidget != NULL ); | |
| QLabel *label = qobject_cast<QLabel *>(obj); | |
| Q_ASSERT( label != NULL ); // label is 0(NULL). because obj is not inherited from QLabel. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment