Results 1 to 2 of 2

Thread: QGraphicsScene infinite update

  1. #1
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QGraphicsScene infinite update

    Hi every body!

    I have 2 viewports each one has a different qgraphicscene and each viewport has a ItemView class for generating QGraphicsItem from my custom model like this

    Qt Code:
    1. myviewport::myviewport(QWidget* parent) ...
    2. {
    3. myscene = new MyScene(this);
    4. setScene(myscene);
    5.  
    6. viewWrapper = new MyItemView(this);
    7. }
    8.  
    9. MainWindow::MainWindow()
    10. {
    11. mainView = new myviewport(this);
    12. subView = new myviewport(this);
    13.  
    14. myModel = new MyModel(this);
    15. mainView->setModel(myModel);
    16. subView->setModel(myModel);
    17. }
    To copy to clipboard, switch view to plain text mode 

    when I hide subView everything works great, if I change model from different tablewidget, my graphics item change too without any problem. but each time I show subView, subView has the Items too but qgraphicsscene go to infinite loop of updating (i have a breakpoint in drawBackground function of myscene and its call every time),

    however if I haven't any qgraphicsitem in my viewwrapper, everythings works good when two views are visible.

    its really strange behavior for me, the viewwrapper doesn't get any signal, model don't change at all just change the visiblity of subView to show and my viewports freeze, Other widgets work yet.

    So witch functions of a qgraphicsitem can cause of updating a whole scene?

    when i trace item creation in model, each viewwrapper create a QGraphicsItem for parent scene correctly, after this I correctly didn't get any signal of dataChanged or reset model too.

    the code is complicated and big so i described what i did in my program thanks in advance.

  2. #2
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene infinite update

    I found the problem, I call prepareGeometryChange() of some items in drawbackground() function of myscene, but yet I didn't understand why this is a problem in two view but not in one view. however i think my program has some important bugs yet.

Similar Threads

  1. Update a QGraphicsScene every x seconds automatically
    By Nezgal in forum Qt Programming
    Replies: 2
    Last Post: 26th May 2013, 07:55
  2. QGraphicsScene::update() has no effect
    By pmwalk in forum Newbie
    Replies: 4
    Last Post: 24th February 2012, 16:10
  3. Update QGraphicsScene - Best Practice
    By vinaykusta in forum Qt Programming
    Replies: 0
    Last Post: 4th November 2011, 04:52
  4. Can't manually update QGraphicsScene
    By aladagemre in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2010, 21:52
  5. QGraphicsScene update?
    By Gurdt in forum Qt Programming
    Replies: 11
    Last Post: 17th April 2009, 09:03

Tags for this Thread

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.