Results 1 to 13 of 13

Thread: QGraphicsItem is not drawn again?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default QGraphicsItem is not drawn again?

    Hi all,

    I have the following problem;

    I have a scene and items in it. Once I zoom in the scene, some of the items go off the scene normally. But when I zoom out, I don't the items that are there before I zoomed in.

    What could be the possible problem?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem is not drawn again?

    What happens if you zoom so, that for example an item is only half out site the view area, and then zoom back, will you see the whole object item again, or only the part that was not zoomed "out"?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsItem is not drawn again?

    If only a part of an item is seen after zooming in, then no problem after zooming out. If the item is completely off the scene after zooming in, then nothing appears about the item.

    Is it more clear now?

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem is not drawn again?

    can you show your zooming code?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsItem is not drawn again?

    I'm afraid I can't.

    But you see the problem is not about zooming. I guess I failed in updating of the relevant items issue or the scene itself.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem is not drawn again?

    But you see the problem is not about zooming. I guess I failed in updating of the relevant items issue or the scene itself.
    Probably, but that should be visible in the zooming code, since then we can see what happens when you zoom out again...

    But without code it very hard to help...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsItem is not drawn again?

    Batu olm bi gavra hele ya felaket sıkıldım. batu olmazsa seyhun o da olmazsa bu işin ordinasyüsü levent.

  8. #8
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsItem is not drawn again?

    The problem here is basicly because of item's removal from the scene bounding rect. So how can I put the item back into the scene rectangle when it's gone out of it by zooming in action , if I zoom out in the scene again?

  9. #9
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem is not drawn again?

    Why are you managing yourself the items viewed in your scene?

    Since Qt do the job for you and compute the visible items based on QGraphicsItem::boundingRect, you will get in QGraphicsView::drawItems the list of visible items.
    So no need to remove or add items.

    Are you computing the zoom yourself in the scene, in your custom items or elsewhere?

  10. #10
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsItem is not drawn again?

    I guess you misunderstood me. I didn't remove or add items when I zoom in or zoom out. This is what I think as a possible reason that the items are no longer visible once they are off the scene's bounding rectangle. It is also strange that the program still enters item's paint method although it's not drawn.

    I deal zooming stuff in the view by the way.

  11. #11
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem is not drawn again?

    So that means that the item are seen by Qt, according to its bounding rect.

    Can you post a simplified version of your zoom function?

    There is probably a coordinates conversion error of your items position, so they are drawn out of the viewed rect.

    Another questions :
    * Why not using Qt built-in QGraphicsView::scale?
    * Do you manage derived QGraphicsItem with overloaded paint?

  12. #12
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsItem is not drawn again?

    Hi,

    sorry but I can't because I'm using different library for such operations(zooming, rotating etc.) and the functions are hidden which means not available. I just called setRange(+/- rangeAmount) and it does. Sorry fot that.

    By the way, don't you think that items would have drawn wrongly at the begining or at the situations in which the items are in still scene's rectangle if there is a coordinate error?

    Anyway regarding your last questions,

    I didn't prefer to use it because I deal with geographic coordinates( latitudes and longitudes) so that's why we use different library as I mentioned.

    And I don't think my paint functions are overloaded. They're just dealing with paint issues.

Similar Threads

  1. QGraphicsItem doesn't inherit QObject?
    By xyzt in forum Qt Programming
    Replies: 6
    Last Post: 26th September 2011, 14:59
  2. Replies: 2
    Last Post: 25th March 2011, 09:18
  3. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  4. Replies: 1
    Last Post: 25th February 2009, 00:34
  5. QGraphicsScene - order of images drawn
    By bjh in forum Qt Programming
    Replies: 2
    Last Post: 29th November 2007, 15:41

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.