Results 1 to 2 of 2

Thread: QGraphicsView won't update until resize

  1. #1
    Join Date
    Apr 2008
    Posts
    29
    Thanks
    5
    Thanked 1 Time in 1 Post

    Unhappy QGraphicsView won't update until resize

    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

  2. #2
    Join Date
    Apr 2008
    Posts
    29
    Thanks
    5
    Thanked 1 Time in 1 Post

    Smile Re: QGraphicsView won't update until resize

    I believe that I have resolved this. I am going to post what I found here, in the hopes that it will help someone else with the same problem. I am also going to sent a bug report to trollTech/Nokia, because I think that this is basically a bug in QT.

    If you call show on the view before the view is connect to a scene, the view gets into a state where it has refresh problems from then on. Perhaps there is a way to make it recover from this state, but I don't see it. If you call show only after there is a scene associated with the view, everything is fine.

  3. The following user says thank you to stevel for this useful post:

    nifei (5th March 2009)

Similar Threads

  1. Qt Update project - Opinions wanted
    By pvdk in forum Qt Programming
    Replies: 0
    Last Post: 8th November 2008, 09:41
  2. getting QGraphicsView to resize
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2008, 04:49
  3. why there is no update on maximize? [QTableWidget]
    By macias in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 16:01
  4. QGraphicsScene / QGraphicsView speed after resize
    By themolecule in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2007, 00:46
  5. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 01:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.