Results 1 to 3 of 3

Thread: Insert image to QGraphicView

  1. #1
    Join Date
    Mar 2013
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Insert image to QGraphicView

    Hi everyone,

    I want to ask, how to insert an image to QGraphicView from file? I already have the file path, but I don't know how to insert it actually.
    Could you please help me?
    Thank you!

    Best regards!

  2. #2
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Insert image to QGraphicView

    use graphicspixmapitem

    QGraphicsScene scene;
    scene.setSceneRect( x, y, z, z );
    QGraphicsPixmapItem *item = new QGraphicsPixmapItem(QPixmap("mine.png"), &scene);
    QGraphicsView view( &scene );
    "Behind every great fortune lies a crime" - Balzac

  3. #3
    Join Date
    Dec 2012
    Posts
    90
    Thanks
    5
    Thanked 20 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Insert image to QGraphicView

    You can create QPixmap, then load it from file, and then create QGraphicsPixmapItem with this pixmap and add it to your scene.
    http://qt-project.org/doc/qt-4.8/qpixmap.html
    http://qt-project.org/doc/qt-4.8/qgr...ixmapitem.html

Similar Threads

  1. How to insert an image through Qt
    By thanisha in forum Newbie
    Replies: 1
    Last Post: 26th June 2010, 05:55
  2. Replies: 2
    Last Post: 6th April 2010, 15:00
  3. insert image at the bottom of QTextEdit
    By Cortex in forum Qt Programming
    Replies: 12
    Last Post: 24th October 2009, 15:22
  4. Insert image in RTL QTextEdit problem!
    By SudaNix in forum Newbie
    Replies: 2
    Last Post: 23rd October 2009, 22:53
  5. How to insert an image in background of a Form?
    By awanish_jmi in forum Qt Tools
    Replies: 2
    Last Post: 8th August 2008, 10:52

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.