[quote author="stereomatching" date="1385677858"]
What I mean is "please give me a full example which could reproduce your problem with minimum lines of codes"[/quote]
I thought you need less.
[quote author="Sergei Eliseev" date="1385743150"]
What thread calls MyItem::myItem_update_Slot()?[/quote]
MyItem::myItem_update_Slot() calls on timer signal. I don't use multi-threading in my code. Here I connect timer with update():
@
MyModel::MyModel( QObject *parent ) : QObject( parent )
{
myitem = new MyItem();
mytimer = new QTimer;
mytimer -> setInterval( 100 );
connect(mytimer, SIGNAL(timeout()), myitem, SLOT(myItem_update_Slot()));
mytimer -> start();
}
@
And the less of the code once again:
@
void MyItem::myItem_update_Slot()
{
x = rand() % 1400;
y = rand() % 1400;
j = rand() % 100;
k = rand() % 100;
update();
}
void MyItem::paint( QPainter *painter )
{
img = sourceImage.copy( x, y, 100, 100 );
painter -> drawImage( QPoint( j, k ), img );
// flying rect
// painter -> fillRect( j, k, 50, 50, Qt::black );
}
// main.qml
import QtQuick 2.0
import MyItem 1.0
Rectangle {
width: 360
height: 360
MyItem{
width: 300
height: 300
}
}
@
[quote author="Sergei Eliseev" date="1385743150"]
For test's sake put an animated object[/quote]
Thanks for the idea, I've checked it as demonstrated above (if I got it right). update() is being called, but repaint isn't done. I suspect that it can be related to the visibility scope of vars inside paint() during update() calling.