Qt-interest Archive, August 2007
QGraphicsView Issues Upgrading from 4.2->4.3
Message 1 in thread
In trying to upgrade from Qt version 4.2.2 to 4.3.0 I've run into quite
a few issues, but this is by far the most maddening. I have one
QGraphicsView (which can be panned and zoomed around) and one
QGraphicsScene. QGraphicsItems are added and removed from the scene at
any time (based on what is received over the network). My problem is
that the QGraphicsView remains blank even if I know that new
QGraphicsItems have been added to the scene. Once I pan, zoom, or take
focus away from the QGraphicsView (such as by clicking on another window
in another program, or even just clicking on the start menu) then all
the QGraphicsItems properly show themselves. But, if any new items are
added or items are taken away, these changes won't show until a user
interactable update happens.
I've tried programmatically calling update on the scene or view, but
this does nothing. I'm sure my QGraphicsItems have the correct
position, are added correctly to the scene, the view has the proper
position, and the items are shown (everything worked fine in 4.2.2!).
The only programmatic solution I've come up with is to hide() and then
show() my QGraphicsView to force an update and redraw the widget -
however this is going to be a big pain to make sure every single place
in my code with any kind of scene update does this (plus this is a
pretty lame hack). Does anybody have any solutions or suggestions? Thanks,
Chris Portka
--
[ signature omitted ]
Message 2 in thread
On Thursday 02 August 2007, Chris Portka wrote:
...
> I've tried programmatically calling update on the scene or view, but
> this does nothing.
...
In some version of Qt (4.1 or 4.2) I also needed to update a QGraphicsView, or
rather the scene. I tried using:
void QGraphicsScene::update ( const QRectF & rect = QRectF() )
without any parameters in order to update the whole scene (the docs actually
say nothing at all what a plain QRectF() actually updates), but that did
nothing. Could it be that QRectF() actually updates an empty rectangle, but
that would be totally different from how QWidget::update() works? I ended up
using:
myScene->update(myScene->sceneRect());
in order to really get it to do something.
--
[ signature omitted ]
Message 3 in thread
Jan Ekholm wrote:
> On Thursday 02 August 2007, Chris Portka wrote:
>
> ....
>> I've tried programmatically calling update on the scene or view, but
>> this does nothing.
> ....
>
> In some version of Qt (4.1 or 4.2) I also needed to update a QGraphicsView, or
> rather the scene. I tried using:
>
> void QGraphicsScene::update ( const QRectF & rect = QRectF() )
>
> without any parameters in order to update the whole scene (the docs actually
> say nothing at all what a plain QRectF() actually updates), but that did
> nothing. Could it be that QRectF() actually updates an empty rectangle, but
> that would be totally different from how QWidget::update() works? I ended up
> using:
>
> myScene->update(myScene->sceneRect());
>
> in order to really get it to do something.
>
Curiously, this does nothing for me either. I have found that I can
call fitInView() on my QGraphicsView with the regions of the scene I'm
viewing to get it to update properly. However, this still feels hackish
because I now have to insert these every possible place I do an update
on the scene or view. Arg! This looks like it'll make everything a
little slower. There should be an easy way to tell the scene to update
automatically when and how I want it...
-Chris Portka
--
[ signature omitted ]