Results 1 to 8 of 8

Thread: QGraphicsItems Layers

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    20
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default QGraphicsItems Layers

    Hi All

    I am using QGraphics framework for an application to display images and add text, shapes and items over the image. QGraphics framework seems to be a right fit for my need, because i need to allow all the items to be repositioned and editable/ show/hide items etc.

    The challenge however is when i save the image, i do not want the text/items to be burned in.This happens when i render using QPainter.
    While saving the image, i need to save the user created items as a separate layer and preserve the original image.Similarly , when i reload the image, i want to load back the items layer separately, only on demand.

    Could somebody provide suggestions if QGraphics Framework has existing capability to support this ? I would really appreciate any hints. Thank you !

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

    Default Re: QGraphicsItems Layers

    hide() or show() respective items before saving data from the scene.
    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. #3
    Join Date
    Jul 2009
    Posts
    20
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: QGraphicsItems Layers

    Thanks for the answer. I think i should explain the problem better.

    Hide()/Show() can be used while the image is currently loaded. But, when i save the image, the text/items are burned into the image.I can use hide() and save only the image, but subsequently when i reload the image, i need to have access to the created items.

    I am hoping there would be a way to save the item layer as a separate format/file, and while recalling the original image if the user likes to view the items, load the item layer also, else load only the image.

    Else, am i missing something ? Would really appreciate feedback.

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

    Default Re: QGraphicsItems Layers

    Quote Originally Posted by qtuser20 View Post
    I can use hide() and save only the image, but subsequently when i reload the image, i need to have access to the created items.
    Save them in another file and reload when you need 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.


  5. #5
    Join Date
    Jul 2009
    Posts
    20
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: QGraphicsItems Layers

    Hi

    Instead of loading them as separate images, is there a way to overlay or combine them , so that this process is not transparent to the user .

    Thanks

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

    Default Re: QGraphicsItems Layers

    Overlay or combine into what? You need a file to save to. You either save your image as image and the rest as a separate file or you save everything in one file, losing direct access to the image.
    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.


  7. #7
    Join Date
    Jul 2009
    Posts
    20
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: QGraphicsItems Layers

    For the save operation, i initially hide() the items and save out the image A.

    Then, i show() the items and use setbackgroundbrush to white to save out only the items file. Lets call this image B.I do this because image files are larger and would be better to store only items.

    When i load back image A, i would like to have a menu control that allows user to choose the items file. When the user loads image B , the contents of items should appear over image A.ie it should appear as if the items are drawn over image A .

    I think i should not be using setbackgroundbrush(Qt:white) to store the items file.Is there an alternative suggestion?

    Thankyou

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

    Default Re: QGraphicsItems Layers

    If you don't need to do anything with the items after reloading them then you can make the image an item as well and hide the item before saving other items. Graphics scene is by default transparent so you'll get a proper effect (alternatively set the background brush to transparent colour). When reloading, load the two saved images as items.

    This only makes sense if you don't want to interact with the items after reloading them. I would suggest to do something else. Use your own binary format to save both the image and the items into a file so that you can later reload both the image and the items (as items, not as a bitmap) and in addition to that provide an export functionality to save the background (and possibly other items if the user wants to) as image file.
    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. The following user says thank you to wysota for this useful post:

    qtuser20 (10th August 2009)

Similar Threads

  1. Copy and Paste of QGraphicsItems in a Scene
    By subash in forum Qt Programming
    Replies: 6
    Last Post: 6th July 2011, 15:15
  2. qt 4.4 Issue with too many QGraphicsItems
    By spawn9997 in forum Qt Programming
    Replies: 6
    Last Post: 2nd September 2009, 15:56
  3. Application 3-tiers (multi layers)
    By estanisgeyer in forum Qt Programming
    Replies: 2
    Last Post: 13th February 2009, 17:28
  4. How to put scaled QGraphicsItems next to eachother
    By profoX in forum Qt Programming
    Replies: 6
    Last Post: 3rd June 2008, 07:44
  5. Replies: 3
    Last Post: 11th April 2008, 12:25

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.