0
以前我張貼在如何訪問QML結構問題和一些真棒人得到了完美的答案,現在我需要知道的是,有沒有什麼辦法來訪問結構內結構QML,以下是代碼:訪問結構的結構裏面QML
// MyNewStruct
struct MyNewStruct {
Q_GADGET
float m_range;
Q_PROPERTY(float range MEMBER m_range)
};
// MYSTRUCT
struct MyStruct {
Q_GADGET
int m_val;
QString m_name1;
QString m_name2;
QString m_name3;
QString m_name4;
MyNewStruct m_newStr; //**new Struct declaration
Q_PROPERTY(int val MEMBER m_val)
Q_PROPERTY(QString name1 MEMBER m_name1)
Q_PROPERTY(QString name2 MEMBER m_name2)
Q_PROPERTY(QString name3 MEMBER m_name3)
Q_PROPERTY(QString name4 MEMBER m_name4)
Q_PROPERTY(MyNewStruct newStr MEMBER m_newStr) //**Currently getting error as != cannot be used
};
什麼是錯誤? – dtech
'錯誤:不對應的 '!運算符='(操作數的類型是 'myStruct1' 和 'myStruct1') 如果(_t-> mynewstr = *的reinterpret_cast < myStruct1*>(_v)!){' ^ **其中Mystruct1是myNewStruct ** – pra7
我不擅長C++,但是我可能會問,爲什麼你使用'reinterpret_cast'?我認爲幾乎沒有情況下,這種演員是必要的......但正如我所說,我只是現在學習C++ ;-) – derM