Results 1 to 2 of 2

Thread: Graphics View basic usage help

  1. #1

    Question Graphics View basic usage help

    Hello, I am trying to build a GUI for my OpenCV program. I would like to use Graphic View to display the processed image from OpenCV.

    However, as a Qt newbie I am stuck with the basic usage of displaying a pixmap (which I planned to use for my OpenCV images). Following is the the C++ code I wrote to display a 100x100 pixel red pixmap. "gui" is the UI created with Designer (which contains a Qgraphicsview widget). The code compiles but when it runs the pixmap is not shown.

    Please tell me what is wrong my code and how should I correct it. Thank you for your help!

    Qt Code:
    1. gui.setupUi(this);
    2. QGraphicsScene GCSscene;
    3. QPixmap* GCSpixmap = new QPixmap(100,100);
    4. GCSpixmap->fill(QColor(255,0,0));
    5. QGraphicsPixmapItem* GCSpixmapitem = GCSscene.addPixmap(*GCSpixmap);
    6. (gui.graphicsView)->setScene(&GCSscene);
    7. (gui.graphicsView)->show();
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Graphics View basic usage help

    You are probably using a local variable that goes out of scope and gets destroyed.
    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.


Similar Threads

  1. Graphics/View + dialogs
    By AeroB in forum Qt Programming
    Replies: 2
    Last Post: 19th June 2012, 15:39
  2. Graphics View : too many lines
    By natnan in forum Qt Programming
    Replies: 6
    Last Post: 28th January 2010, 12:15
  3. Graphics View and the Pixmap
    By spawn9997 in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2009, 23:12
  4. OpenGL with Graphics View?
    By Dutch112 in forum Qt Programming
    Replies: 15
    Last Post: 19th May 2009, 09:21
  5. graphics view slow
    By dognzhe in forum Qt Programming
    Replies: 16
    Last Post: 11th May 2009, 18:36

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.