找回密码
 立即注册
收起左侧

QML使用c++类/对象

1
回复
5602
查看
[复制链接]
累计签到:2 天
连续签到:1 天
来源: 2016-7-5 17:21:28 显示全部楼层 |阅读模式
1Qter豆
本帖最后由 longxh 于 2016-7-5 19:05 编辑

QT新手求助!
我参考http://blog.csdn.net/foruok/article/details/32698603新建了ColorMaker类
第一种方法注册类,在main.cpp中使用
    qmlRegisterType<ColorMaker>("an.qt.ColorMaker", 1, 0, "ColorMaker");
注册,在main.qml中添加了
    import an.qt.ColorMaker 1.0
编译完成,但是运行时会显示:
    module "an.qt.ColorMaker 1.0" is not installed
请问是怎么回事呢?


回复

使用道具 举报

尚未签到

2016-7-6 00:03:41 显示全部楼层
void QQmlContext::setContextProperty(const QString & name, QObject * value)
Set the value of the name property on this context.
QQmlContext does not take ownership of value.
See also contextProperty().


这个可以将c++的对象映射的qml里面
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了