对从c++中向qml中导入list<qobject*>的操作的深入学习
来源:互联网 发布:少儿趣味编程课程 编辑:程序博客网 时间:2024/06/11 00:22
在qml中对数组Array可以进行push [index] .length clear;等操作
而从c++中向qml中导入list
//这里是实例化一个QQmlListProperty,分别使用这四个函数指针QQmlListProperty<Person> BirthdayParty::guests(){ return QQmlListProperty<Person>(this, this, &BirthdayParty::appendGuest, &BirthdayParty::guestCount, &BirthdayParty::guest, &BirthdayParty::clearGuests);// return QQmlListProperty<Person>(this, m_guests);}//这是最终执行的函数void BirthdayParty::appendGuest(Person* p) { qDebug() << "appendGuest1"; m_guests.append(p);}int BirthdayParty::guestCount() const{ return m_guests.count();}Person *BirthdayParty::guest(int index) const{ return m_guests.at(index);}void BirthdayParty::clearGuests() { qDebug() << "lll"; while(m_guests.size() > 0) { m_guests.takeFirst()->destroyed(); }// return m_guests.clear();}// ![0]//这三个函数是在qml中分别操作"push" "=[]" "[index]" ".length"时使用的void BirthdayParty::appendGuest(QQmlListProperty<Person>* list, Person* p) { qDebug() << "appendGuest2"; reinterpret_cast< BirthdayParty* >(list->data)->appendGuest(p);}void BirthdayParty::clearGuests(QQmlListProperty<Person>* list) { qDebug() << "clearGuests"; reinterpret_cast< BirthdayParty* >(list->data)->clearGuests();}Person* BirthdayParty::guest(QQmlListProperty<Person>* list, int i) { qDebug() << "guest"; return reinterpret_cast< BirthdayParty* >(list->data)->guest(i);}int BirthdayParty::guestCount(QQmlListProperty<Person>* list) { qDebug() << "guestCount"; return reinterpret_cast< BirthdayParty* >(list->data)->guestCount();}
阅读全文
0 0
- 对从c++中向qml中导入list<qobject*>的操作的深入学习
- java中对集合List的操作
- c:forEach中对List的遍历
- Qt中QObject::sender()的用法
- Qt中QObject::sender()的用法
- Qt中QObject::sender()的用法
- Qt中QObject::sender()的用法
- C语言中对文件的操作
- C中对SQL Server的操作
- C语言中对文件夹的操作
- C中对堆的操作函数
- C语言中对文件的操作
- C语言中对文件的操作
- C语言中对文件的操作
- C语言中对文件的操作
- 对C中操作符的认知
- WPF中对Excel文件的导入导出操作详解
- WPF中对Excel文件的导入导出操作详解
- Spring Security4 CSRF 如何关闭CSRF功能
- 推荐:Nginx 会话黏着一致性解决
- JSP中获取IP地址的方法
- 数图的量化:灰度处理
- Windows Practice_内存映射_加载BMP
- 对从c++中向qml中导入list<qobject*>的操作的深入学习
- bzoj1415 [Noi2005]聪聪和可可(期望概率DP+最短路)
- Javascript异步编程(三: Thunk函数)
- JS笔记——跨域
- HDU
- 二叉堆&优先队列-----noip2004 合并果子
- Java Collection
- 科大讯飞笔试题
- 完全配置java环境变量