In my project, I have a QGraphics view that I can add various kinds of QGraphicsItems to. I recently refactored some code, and after this change, the QGraphicsView no longer refreshes when I add a new item, when I move an item, or resize an item.

When I click on an item, and move the mouse, nothing changes on the screen until I resize the window, at which time, the view is redraw with the item in the new location.

I'm running QT 4.4.3 on a Mac running OS X 10.4.

I've searched the forum, and seen that several other people have posted very similar questions, but no one posted the answer to how they solved the problem.

When I resize the window containing the scene, everything redraws, and the moving/resizing I have done shows up.

I do have some code associated with the mouse events, but this code seems to be working as far as I can tell.

I think I could fix this by adding lots of update calls through out the code, but I don't think I should need to do this.

Here's the code where the view is initialized:

Qt Code:
  1. worksheetScene = new QGraphicsScene();
  2. itsDrawList = new EWorksheetView(this);
  3.  
  4. // JSL - single sceneDrawCommon for common drawObject behavior
  5. sceneDrawCommon = new EDrawCommon();
  6. worksheetScene->addItem(sceneDrawCommon);
  7.  
  8. itsDrawList->setScene(worksheetScene);
  9. setWidget(itsDrawList);
To copy to clipboard, switch view to plain text mode 

Here's the creator for the view:
(EDrawListView is an ancestor for EWorksheetView

Qt Code:
  1. //
  2. // JSL - EDrawListView
  3. //
  4. EDrawListView::EDrawListView(EDrawListWindow *aWindow)
  5. {
  6. itsWindow = aWindow;
  7.  
  8. wkDefaultColor = QColor(100, 100, 100, 255).rgba();
  9. wkAntiAliasing = true;
  10.  
  11. setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
  12. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  13. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  14. setDragMode(QGraphicsView::RubberBandDrag);
  15. setAcceptDrops(true);
  16.  
  17. show();
  18. }
To copy to clipboard, switch view to plain text mode 


If anyone has any suggestions, I would appreciate hearing them. Also, if anyone wants to see the Event code, let me know.

Thanks