[Qt-qml] [Solved] How to trigger a QML redraw from C++

Tarantism tarantism at ntlworld.com
Wed May 25 22:04:41 CEST 2011


On Tue, 2011-05-24 at 23:08 +0100, Tarantism wrote:
> I'm writing a hybrid c++/qml application. I'm creating new items by
> creating QDeclarativeItem derivatives (over-riding their paint() method)
> and using their setParent method to put them in the 'scene'.
> 
> They appear properly on creation but I need to update their rendering
> regularly based on c++ events.
> 
> How do I tell the QML engine to redraw these items? I've tried calling
> update() on the items and their parents with no effect.

As it turns out, update() was working correctly and the item's paint
methods were being called but for some reason, the screen was not
updating.

I've stopped using setParent to put the QDeclarativeItem derivatives in
the scene directly.

Instead, I'm using qmlRegisterType on the QDeclarativeItem derivatives
and creating them within a qml wrapper file. I make a new
QDeclarativeItem from the qml wrapper file and add that to the scene
using setParent ...



More information about the Qt-qml mailing list