Proper way to check QObject derived class type in Qt

后端 未结 1 546
余生分开走
余生分开走 2021-02-13 03:53

Lets say I have a two classes:

class A : public QObject {};
class B : public QObject {};

then I go

QObject *a = new A();
QObje         


        
相关标签:
1条回答
  • 2021-02-13 04:26

    You can use qobject_cast<MyClass*>(instance) on QObject derived classes and check the return value. If instance cannot be cast to MyClass*, the return value will be NULL.

    0 讨论(0)
提交回复
热议问题