Results 1 to 20 of 20

Thread: How to draw a Qgraphicsitem on a Qimage?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,324
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to draw a Qgraphicsitem on a Qimage?

    @thinker: I am not clear on exactly *what* it is that you want your users to be able to flood fill - the graphical items they have added, the background, what? You should think about composing your scene in layers, by using the z-value property of graphics items. Items with a higher z-value will clip items with lower z-value (ignoring transparency for now), so in essence the scene will do all of the work needed to calculate intersections and such. Whatever you want to flood fill should have a lower z-value than the things on top.

    I agree with Wysota - you are going about this totally backward if you think that -you- need to convert your scene to an image and do all the work of filling flooded areas yourself. All the tools are there in the Graphics / View architecture, you just need to learn how to use them.

  2. #2
    Join Date
    Feb 2012
    Posts
    12
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: How to draw a Qgraphicsitem on a Qimage?

    Quote Originally Posted by d_stranz View Post
    @thinker: I am not clear on exactly *what* it is that you want your users to be able to flood fill - the graphical items they have added, the background, what?
    Think about flood filling in a typical drawing application - this case is just the same.

    So users might draw circles, rectangles, and free hand curves which are not closed.
    And a flood fill might fill a complex closed shape made by free hand lines, or leak out of an open shape and fill the whole background.

    And user might really click anywhere, not just on the lower z valued items. May be on the very lines themselves!

  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: How to draw a Qgraphicsitem on a Qimage?

    Does the fill create a new object or modify existing ones?
    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.


  4. #4
    Join Date
    Feb 2012
    Posts
    12
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: How to draw a Qgraphicsitem on a Qimage?

    Quote Originally Posted by wysota View Post
    Does the fill create a new object or modify existing ones?
    It can be done either way, depending upon what supports the logic better.
    The aim here is just to create floodfill. So a new object can be created if required!

  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: How to draw a Qgraphicsitem on a Qimage?

    There's a fundamental difference between the two. If you don't care about it then maybe you shouldn't be using graphics view at all? If you're just after raster painting then there are no benefits in using graphics view and you can reduce your implementation to a widget displaying QPixmap/QImage.
    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. #6
    Join Date
    Feb 2012
    Posts
    12
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: How to draw a Qgraphicsitem on a Qimage?

    Quote Originally Posted by wysota View Post
    There's a fundamental difference between the two. If you don't care about it then maybe you shouldn't be using graphics view at all? If you're just after raster painting then there are no benefits in using graphics view and you can reduce your implementation to a widget displaying QPixmap/QImage.
    As I have mentioned in the question, the most recent item is editable by the user.
    ie, it can be dragged around, resized and rotated before the final permamnent version is drawn.
    I thought this could be easier to implement with QGraphicsView

  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: How to draw a Qgraphicsitem on a Qimage?

    Quote Originally Posted by eternalthinker View Post
    As I have mentioned in the question, the most recent item is editable by the user.
    ie, it can be dragged around, resized and rotated before the final permamnent version is drawn.
    I thought this could be easier to implement with QGraphicsView
    That doesn't require graphics view. Nevertheless my question still stands -- if your fill is to create a new "most recent item" that is to be "editable by the user" then it is much different from filling an existing item or canvas.
    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.


  8. #8
    Join Date
    Feb 2012
    Posts
    12
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: How to draw a Qgraphicsitem on a Qimage?

    Quote Originally Posted by wysota View Post
    That doesn't require graphics view. Nevertheless my question still stands -- if your fill is to create a new "most recent item" that is to be "editable by the user" then it is much different from filling an existing item or canvas.
    Actually 'editable' apply to only a selected few items in the application. This excludes floodfills and freehand lines.

Similar Threads

  1. How to draw QGraphicsItem at the same location?
    By jeanremi in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2011, 16:08
  2. Replies: 10
    Last Post: 10th February 2011, 23:31
  3. Zooming a qimage on a QGraphicsItem
    By paolom in forum Qt Programming
    Replies: 14
    Last Post: 23rd June 2010, 08:47
  4. Replies: 0
    Last Post: 16th August 2009, 17:46
  5. QPainter doesn't seem to draw QImage
    By Denarius in forum Qt Programming
    Replies: 7
    Last Post: 3rd March 2009, 14:12

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