Results 1 to 2 of 2

Thread: Image with on top widgets

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Image with on top widgets

    Hi,

    I would like to show an image that have to have widgets on top of it. Think on a image that shows a paper and 2 lineedits that show the dimensions of the paper.

    What I want to do is what SCADA systems do. It shows a representation of a machine and some widgets ont top of the image that show information and let the user change them.

    Which is the best approach to do this?
    Using a QGraphicsView? What about the position of the widgets when the view is reseized?

    Thank you,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Image with on top widgets

    QGraphicsView would probably work for this. I would create a QGraphicsPixmapItem that contains your image. I would then add the line edits as children of this pixmap item so that they scale and translate according to the coordinates of the pixmap, not the coordinates of the scene.

    If you add all three items as children of the main scene, then they are independent as far as scaling and translation are concerned. Adding the line edits as children of the pixmap ensures they move and scale with it. If you want the line edits to stay the same size regardless of the size of the pixmap, then set the QGraphicsItem::ItemIgnoresTransformations flag for them. They will still move, but will stay the same size.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    ^NyAw^ (25th October 2017)

Similar Threads

  1. set an image behind all child widgets
    By quantumpilgim in forum Newbie
    Replies: 2
    Last Post: 4th September 2016, 13:17
  2. how to get image height and width in qt
    By iswaryasenthilkumar in forum Newbie
    Replies: 1
    Last Post: 31st March 2015, 07:52
  3. Setting width of widgets from QSplitter?
    By adutzu89 in forum Newbie
    Replies: 4
    Last Post: 24th May 2014, 14:07
  4. Replies: 1
    Last Post: 5th March 2013, 08:04
  5. Replies: 1
    Last Post: 15th August 2011, 19:17

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.