【发布时间】:2015-09-29 15:15:03
【问题描述】:
有没有办法在 QML 中访问 C++ 对象的成员变量?在main.cpp 中,我向 QML 公开了一个对象。如何在 QML 中访问 controller.x?
Controller ctrl;
QQuickView view;
QQmlContext* ctx = view.rootContext();
ctx->setContextProperty("controller", &ctrl);
在控制器中:
public:
int x;
【问题讨论】: