Results 1 to 3 of 3

Thread: Best way to display images that must overlap and be moved at run-time?

  1. #1

    Default Best way to display images that must overlap and be moved at run-time?

    I have a set of images that need to be rendered.

    The first image is essentially a "background" image that shows a grid of some sort.

    Every other image is meant to be rendered on top of the background image. They're sized to cover a non-fractional number of cells of the background image/grid. They're allowed to overlap each other. At run time the user will have the ability to shift these images up, down, left, or right in increments equal to the size of a cell in the background image.

    What is the best way to meet these requirements in Qt?

    QGridLayout seems inappropriate because the images couldn't span multiple cells or be rendered on top of each other. I'm looking into QGraphicsScene but it isn't immediately obvious if this is appropriate.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Best way to display images that must overlap and be moved at run-time?

    Definitely not a layout but QGraphicsView.

    For the background either an item or deriving from QGraphicsScene and implementing drawBackground.

    Cheers,
    _

  3. #3

    Default Re: Best way to display images that must overlap and be moved at run-time?

    I've been looking into QGraphicsScene. It looks like I'd use QGraphicsPixmapItem to display images and it looks like I can use QGraphicsItem::setFlag(QGraphicsItem::GraphicsItem Flag::ItemIsSelectable, true) to allow each image to be select-able via mouse clicks.

    However, my application needs to respond when an item is selected (for example, it needs to de-select items in a separate QGraphicsScene) and it isn't clear how to propagate item selection events to my application code. Do I have to override QGraphicsPixmapItem and emit a custom signal?


    Added after 44 minutes:


    ...I think I've answered my own question. It looks like you can get the item selection events indirectly by listening to the QGraphicsScene::selectionChanged() signal and then use QGraphicsScene::selectedItems() to see which items are selected.
    Last edited by EdLaFave; 12th January 2017 at 18:09.

Similar Threads

  1. How to sort images in Qt based on Time
    By iswaryasenthilkumar in forum Newbie
    Replies: 4
    Last Post: 11th February 2015, 11:10
  2. Replies: 2
    Last Post: 6th May 2014, 08:29
  3. How to display DDS images?
    By jamsession in forum Qt Programming
    Replies: 5
    Last Post: 12th June 2013, 22:18
  4. Replies: 0
    Last Post: 9th November 2010, 07:58
  5. Displaying real time images
    By Sheetal in forum Qt Programming
    Replies: 9
    Last Post: 22nd February 2007, 11:29

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.