如何创建用于QML的通用对象模型?
AnimalModel
(http:/doc.qt.io/qt-5/qtQuick-Modelviewsdata-cppmodel s.html#qabopactitemmodel).
QuickView view;view.rootContext()->setContextProperty("myModel", &model);
view.rootContext()->setContextProperty("obj", pDataObject);
class DataObject : public QObject{ Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) ... AnimalModel m_modelAnimals; //Is this possible in any way? //Q_PROPERTY(AnimalModel modelAnimals READ modelAnimals NOTIFY modelAnimalsChanged)};
QAbstractListModel
QQmlListProperty
QQmlListProperty
幕布斯7119047
相关分类