Results 1 to 7 of 7

Thread: graphicsview Problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default graphicsview Problem

    HI,

    I have been having some problems with graphics view.I tried to create a view which has 100 items.My problems are as follows:

    1)Any small change sresults in 8 paint events.Can I somehow minimise them??
    2)I would like to update only a part of the view sometimes can i do it??

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: graphicsview Problem

    1)Any small change sresults in 8 paint events.Can I somehow minimise them??
    Well, without knowing your sourcecode, no one can say that.
    2)I would like to update only a part of the view sometimes can i do it??
    Please have a look at the docs QGraphicsView::ViewportUpdateMode and QWidget::update( const QRect & r )

    Lykurg

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: graphicsview Problem

    Quote Originally Posted by tampstaffs View Post
    2)I would like to update only a part of the view sometimes can i do it??
    The view is by default updated only in those parts that map to the part of the scene containing modified items.

  4. #4

    Default Re: graphicsview Problem

    hi ,
    Thanks for the reply.

    My problem is ,I have QGraphicsItems in the scene.When I try to update one of them, paint event is generated for it.And when it updates it self, for some reason its generating paint event fpr other items.I would like to minimise this, either to one paint event where all of them are updated at one time or that only th eitem I want is updated.

    Aare there any tips and tricks to improve graphics view performance.When i start scrolling for example:
    there are about 3 paint for each graphics items which is killing the performance.

    I have created a scrollable area myself which inherits from QGraphicsWidget, Graphics items are added to this.but this multi paint events on the same items is proving costly during scrolling and even when application is being launched

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: graphicsview Problem

    Quote Originally Posted by tampstaffs View Post
    My problem is ,I have QGraphicsItems in the scene.When I try to update one of them, paint event is generated for it.And when it updates it self, for some reason its generating paint event fpr other items.
    This would suggest the boundingRect() for the item is defined incorrectly.

    I would like to minimise this, either to one paint event where all of them are updated at one time or that only th eitem I want is updated.
    They should all be updated at once (I mean in a single paintEvent() of the viewport). If you experience something different and you are sure about it then there is probably some error in your code.

    Aare there any tips and tricks to improve graphics view performance.When i start scrolling for example:
    there are about 3 paint for each graphics items which is killing the performance.
    Hard to say exactly what is going on without seeing the code. But you may play around with QGraphicsItem::setCacheMode(), maybe it helps.


    I have created a scrollable area myself which inherits from QGraphicsWidget, Graphics items are added to this.but this multi paint events on the same items is proving costly during scrolling and even when application is being launched
    Can't you use what the graphics view offers? If you make your scene bigger than the view, scrollbars will appear by themselves. The reason for the behaviour you observe might be related to the fact that you use QGraphicsProxyWidget (if you do).

  6. #6

    Default Re: graphicsview Problem

    Hi,

    The problem is That I have a structure like this:

    I have a QGraphicsWdget which is more or less acting as a container for all me items.
    Than I have used qgridlayout and added all me items to it .this gridlayout is than set as child to the qgraphicswidget.

    Now when i update any thing,its trying to paint all the scene items.I saw that using cache to gQGraphicItem would reduce repainting.
    If so than where would be the best place to have it,QGraphicsWidget or to the items themselves??

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: graphicsview Problem

    Quote Originally Posted by tampstaffs View Post
    Now when i update any thing,its trying to paint all the scene items.
    That's probably the graphics widget item has to be repainted and that forces a repaint of all items that occupy its boundingRect() which means all items in your case.

    If so than where would be the best place to have it,QGraphicsWidget or to the items themselves??
    If all you want is a grid and you don't intend to resize the widget or anything, I'd suggest getting rid of QGraphicsWidget and positioning items yourself. Then only those items that get modified will get repainted.

Similar Threads

  1. QSound Problem with GraphicsView
    By QbelcorT in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 14th January 2009, 12:28
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. graphicsview performance problem
    By kernel_panic in forum Qt Programming
    Replies: 16
    Last Post: 23rd December 2007, 18:19
  5. GraphicsView rotate problem
    By forrestfsu in forum Qt Programming
    Replies: 7
    Last Post: 21st November 2007, 20:20

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
  •  
Qt is a trademark of The Qt Company.