Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, February 2007
QGraphicsView & Updates/Redraws


Message 1 in thread

Hi,

i am writing an application, which gets data by udp multicast. The  
sender of the udp packets are unique, the data itself are x/y  
coordinates of the sender.

As Display i choosed a QGraphicsView and the sender are derived from  
QGraphicsEllipseItem.
A callback in the implementation of the sender is called after  
receiving a udp datagram. In this callback the position is updated on  
the screen using setPos().

BUT - this does not work, and i do not understand why. In my belief  
QT should redraw the
QGraphicsView after an element gets a new position assigned. I also  
tried to use
QGraphicsScene::update() without any change.

If the scene gets scaled, a redraw is initiated and the new position  
of the element is drawn.
But my sender emit at least every 500ms a new position ...

Does anybody have some suggestions for me how to get this done?


Thanks, Martin

--
 [ signature omitted ] 

Message 2 in thread

On Feb 2, 2007, at 4:14 PM, Jeroen Wijnhout wrote:

> On 2/1/07, Martin Buchleitner <mabu@xxxxxxxxxxxx> wrote:
>> As Display i choosed a QGraphicsView and the sender are derived from
>> QGraphicsEllipseItem.
>> A callback in the implementation of the sender is called after
>> receiving a udp datagram. In this callback the position is updated on
>> the screen using setPos().
>>
>> BUT - this does not work, and i do not understand why. In my belief
>> QT should redraw the
>> QGraphicsView after an element gets a new position assigned. I also
>> tried to use
>> QGraphicsScene::update() without any change.
>
> If it doesn't work after calling update explicitly then there is
> probably something
> wrong with the drawing routine, did you confirm that this works (by
> setting the position manually). Forgetting to add the item to the
> scene is something I forget myself every now and then, so that's also
> something to check.

If i resize the application window, then the paint method is called  
and the item is repainted.
i do not understand, why the paint method is not called, when i set a  
position.

When i use a button within the application to set a view positions on  
an item,
then it is redrawn. so i am confused why this is not done, when the  
position is set
from another thread.


Thanks, Martin

--
 [ signature omitted ] 

Message 3 in thread

On 2/1/07, Martin Buchleitner <mabu@xxxxxxxxxxxx> wrote:
> As Display i choosed a QGraphicsView and the sender are derived from
> QGraphicsEllipseItem.
> A callback in the implementation of the sender is called after
> receiving a udp datagram. In this callback the position is updated on
> the screen using setPos().
>
> BUT - this does not work, and i do not understand why. In my belief
> QT should redraw the
> QGraphicsView after an element gets a new position assigned. I also
> tried to use
> QGraphicsScene::update() without any change.

If it doesn't work after calling update explicitly then there is
probably something
wrong with the drawing routine, did you confirm that this works (by
setting the position manually). Forgetting to add the item to the
scene is something I forget myself every now and then, so that's also
something to check.

best,
Jeroen

--
 [ signature omitted ]