QT中inherits()函数可 判断一个对象的类是不是从另外一个类继承而来
函数原型 bool QObject::inherits ( const char * lname ) const
//来自官方文档
QTimer *timer = new QTimer; // QTimer inherits QObject
timer->inherits("QTimer"); // returns true
timer->inherits("QObject"); // returns true
timer->inherits("QAbstractButton"); // returns false
// QVBoxLayout inherits QObject and QLayoutItem
QVBoxLayout *layout = new QVBoxLayout;
layout->inherits("QObject"); // returns true
layout->inherits("QLayoutItem"); // returns true (even though QLayoutItem is not a QObject)

浙公网安备 33010602011771号