• 5670阅读
  • 1回复

[提问]关于QML中ListView的实时更新问题 [复制链接]

上一主题 下一主题
离线qutonghan
 
只看楼主 倒序阅读 楼主  发表于: 2011-08-03
— 本帖被 XChinux 从 Qt基础编程 移动到本区(2011-08-03) —
我是用C++写的model,如果我在model中临时添加了数据,请问怎样在qml中随即显示出来?刚接触Qt,还请各位大大各显神通。
离线goready

只看该作者 1楼 发表于: 2011-08-29
新人也来学习

01.//main.cpp  
02.#include <QtGui/QApplication>  
03.#include "mainwindow.h"  
04.#include <QDeclarativeEngine>  
05.#include <QDeclarativeComponent>  
06.#include <QDeclarativeItem>  
07.#include <QDebug>  
08.int main(int argc, char *argv[])  
09.{  
10.    QApplication a(argc, argv);  
11.    QDeclarativeEngine *engine = new QDeclarativeEngine;  
12.    QDeclarativeComponent component(engine, QUrl::fromLocalFile("main.qml"));  
13.    QObject *myObject = component.create();  
14.    QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(myObject);  
15.    qDebug()<<item->width();  
16.    item->setProperty("width",200);  
17.    qDebug()<<item->width();  
18.    return a.exec();  
19.}  
快速回复
限100 字节
 
上一个 下一个