Results 1 to 20 of 22

Thread: change bounding of QGraphicsScene

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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 change bounding of QGraphicsScene

    Hi everyone i am newbie in qt programming, i want to change boundary of QGraphicsView or QGraphicsScene from a rectangle to circle, how can i do that?
    i want to create a UI like radar system. main Circle have my svg map and can zoom and pan without any scrollbar and some buttons out of this circle, i think of create a QPixmap and render it frequently and change createbackground() method of QGraphicsScene but i dont know how to implement zooming and padding in this solution.

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

    Default Re: change bounding of QGraphicsScene

    The boundary has to be a rectangle but nothing prevents you from placing a circular item in it and using just that area. If you want to get rid of the background around it then it is also possible, just set the frame of the view to NoFrame and change the palette of the view to make its Base component be either transparent or match the value of the Window component.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    danics (15th July 2012)

  4. #3
    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: change bounding of QGraphicsScene

    thanks for your reply,
    but how can i force QGraphicsScene to show only middle of circle and zoom in and out or panning only my qgraphicssvgitem, whats the best solution? for now i using a custom widget and mask circle area on it and add a qgraphicsview to this widget but this solution isn't good for me, so i googled of any other solution and masking on qgraphicsscene or qgraphicsview itself but without any success, if you explain more your suggestion for me i will thank of you

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

    Default Re: change bounding of QGraphicsScene

    You can enable clipping for the view to only allow drawing on certain area. However that will have impact on performance.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    danics (15th July 2012)

  7. #5
    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: change bounding of QGraphicsScene

    Quote Originally Posted by wysota View Post
    You can enable clipping for the view to only allow drawing on certain area. However that will have impact on performance.
    its not so much good for me, because my svg file is really big so i think i must draw all of my items in a image and paint that and then every-time i m need to scale my map change whole background image, but QGraphicsScene havent paintevent and i dont know when drawbackground() of this class is calling and how to work,
    another problem for me is some graphical widget that i dont need add their to qgraphicsscene( outside of this circle only added to Qgraphicsview)
    can i change paintevent of qgraphicsview for rendering my scene only and dont repaint these widgets?
    or i must create whole of my radar as a QgraphicsItem in this case how can i just repaint this item in whole scene and implement scaling for svg map?

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

    Default Re: change bounding of QGraphicsScene

    Maybe you should start from the beginning and tell us what exactly you are trying to do. I mean, something more detailed than that you're drawing a radar screen.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #7
    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: change bounding of QGraphicsScene

    i say you, you imagine you have a svg map like worldmap that you want add that in the center of some circles like radar, you have some target added in this map and you can select or move them and some button outside of this circle for changing zooming and panning and adding target to this map.

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

    Default Re: change bounding of QGraphicsScene

    Quote Originally Posted by danics View Post
    i say you, you imagine you have a svg map like worldmap that you want add that in the center of some circles like radar, you have some target added in this map and you can select or move them and some button outside of this circle for changing zooming and panning and adding target to this map.
    Sorry, this description is too vague to make out anything of it. I'm asking about your goals, not methods of achieving them.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. The following user says thank you to wysota for this useful post:

    danics (16th July 2012)

  12. #9
    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: change bounding of QGraphicsScene

    Quote Originally Posted by wysota View Post
    Sorry, this description is too vague to make out anything of it. I'm asking about your goals, not methods of achieving them.
    my goals?
    so, loading a large svg file and creating some special map viewer for this file,
    for not confusing anyone else i ask another questions and myself decide how implement that,
    -how can i draw a svg file in background of a QGraphicsScene that cover whole scene?
    -- when scaling a scene my background must scale too?

    tnx for your attention again.

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

    Default Re: change bounding of QGraphicsScene

    Quote Originally Posted by danics View Post
    my goals?
    so, loading a large svg file and creating some special map viewer for this file,
    We won't make progress this way, you know...

    But let's have it your way...

    -how can i draw a svg file in background of a QGraphicsScene that cover whole scene?
    For example using QGraphicsScene::drawBackground()
    -- when scaling a scene my background must scale too?
    It can, it doesn't have to.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #11
    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: change bounding of QGraphicsScene

    but when i use paint method of QGraphicsSvgItem in drawpackground function its size isnt set with the size of scene how can i do this?

Similar Threads

  1. Replies: 2
    Last Post: 1st October 2011, 09:11
  2. How change selected item rectangle on QGraphicsScene
    By xray2000 in forum Qt Programming
    Replies: 1
    Last Post: 18th May 2010, 16:43
  3. Replies: 2
    Last Post: 29th March 2010, 12:34
  4. Getting the bounding rectangle
    By ioannis in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2009, 00:41
  5. Replies: 4
    Last Post: 16th March 2009, 09:08

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.