Results 1 to 6 of 6

Thread: displaying scaled image

  1. #1
    Join Date
    Jan 2011
    Posts
    14
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default displaying scaled image

    hi........
    i have a image where i want to show it on specified Qgraphicsview on the mainwindow. the image display out of specified qgraphicsview with scroll bars. i want the image to show on that specific qgraphicsview.

    chem.jpg is the image

    Qt Code:
    1. QGraphicsScene *scn = new QGraphicsScene( w );
    2.  
    3. w->setScene( scn );
    4. QPixmap pix("/home/karl/Desktop/chem.jpg" );
    5. scn->addPixmap( pix );
    6. w->show();
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: displaying scaled image

    If I understand correctly, you want to resize the image to match the size of graphics view ? Have you tried QPixmap::scaled ?

  3. #3
    Join Date
    Jan 2011
    Posts
    14
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: displaying scaled image

    yeah, i want the image to be displayed in the Qgraphicsview. Can u tell me whr to use Qpixmap::scaled()

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: displaying scaled image

    What have you tried so far ?

  5. #5
    Join Date
    Jan 2011
    Posts
    14
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: displaying scaled image

    Can u tell me where i should modify my code to display the image in specified graphicsview?

  6. #6
    Join Date
    Nov 2010
    Location
    Budapest, Hungary
    Posts
    125
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: displaying scaled image

    I think this would be something like scn->addPixmap( pix.scaled(w->with(),w->height()) );
    but check the documentation for the proper answer.
    Szilvi

Similar Threads

  1. Display full scaled image on a QLabel
    By dcole in forum Qt Programming
    Replies: 2
    Last Post: 10th October 2013, 22:49
  2. Displaying an image
    By seltra in forum Newbie
    Replies: 2
    Last Post: 3rd October 2010, 20:30
  3. as displaying an image in a mdi?
    By Lycus HackerEmo in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2010, 13:14
  4. Displaying image
    By Rui in forum Newbie
    Replies: 1
    Last Post: 20th June 2009, 22:15
  5. Replies: 0
    Last Post: 6th April 2009, 02:20

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.