我有以下代码:
class QtPhysicalComponentAdapter : public QObject
{
Q_OBJECT
Q_PROPERTY(QMaterials FrictionMaterial READ frictionMaterial WRITE setFrictionMaterial DESIGNABLE true USER true)
Q_ENUMS(QMaterials)
public:
enum QMaterials
{
None,
Glass,
Iron
};
QtPhysicalComponentAdapter(CPhysicalComponent* pAdapter):
m_pAdapter(pAdapter)
{}
virtual ~QtPhysicalComponentAdapter(void) {};
QMaterials frictionMaterial() const
{
// Just debug code
return static_cast<QMaterials>(0);
}
void setFrictionMaterial(QMaterials newMat)
{
// Just debug code
m_pAdapter->SetFrictionMaterial(static_cast<CFrictionTable::Material>(0));
}
private:
CPhysicalComponent* m_pAdapter;
}
实际上,我在这个类中有一些其他的Q_PROPERTY,但它们有基本类型,如int,float等。问题是如果我尝试用枚举添加Q_PROPERTY,它编译得很好,但是这个属性没有显示。我在构建输出中找不到任何错误。有谁可以帮助我?