Results 1 to 10 of 10

Thread: no image displayed on QGraphicsView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 127 Times in 121 Posts

    Default Re: no image displayed on QGraphicsView

    Are you sure anything at all is displayed? You instanciate a QGraphicsScene on stack so it gets deleted as soon as the program leaves the scope where it has been created (in this case the open() method...). You'd better allocate it on heap (i.e. using new) or make it a member of your mainwindow class.

    Qt Code:
    1. scene->setSceneRect( -100.0, -100.0, 200.0, 200.0 );
    2. QGraphicsPixmapItem *item = new QGraphicsPixmapItem(QPixmap::fromImage(image), 0, scene);
    3. item->setShapeMode(QGraphicsPixmapItem::BoundingRectSha pe);
    4. //graphicsViewRaw is globally declared as QGraphicsView
    5. graphicsViewRaw->setScene(scene);
    6. graphicsViewRaw->show();
    To copy to clipboard, switch view to plain text mode 

    p.s : next time use put your code within [c o d e] and [/ c o d e] tags (withut spaces... )
    Current Qt projects : QCodeEdit, RotiDeCode

  2. The following user says thank you to fullmetalcoder for this useful post:

    sincnarf (4th October 2007)

Similar Threads

  1. mouse tracking on image
    By vermarajeev in forum Qt Programming
    Replies: 14
    Last Post: 12th May 2010, 14:06
  2. JPEG Image isn't displayed!?
    By GodOfWar in forum Qt Programming
    Replies: 9
    Last Post: 16th April 2007, 16:01
  3. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 15:39
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 17:36
  5. Question about updating an image on screen
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 20:01

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.