Results 1 to 3 of 3

Thread: scaling problem in qpixmap

  1. #1
    Join Date
    Jun 2012
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default scaling problem in qpixmap

    hi
    i am trying to scaled a pixmap to my desktop resolution(1024,600)
    i am using of Qpixmap::scaled(1024,600) but it does not work (it does not changed) please help me?
    QGraphicsScene *j=new QGraphicsScene(0,0,1024,600);
    QPixmap*A=new QPixmap("c:\\...");
    A->scaled(1024,600);(or every size(100,200), ...)
    j->addPixmap(*A);
    mainview.setScene(j);
    mainview.showFullscreen();
    mainview.fitinview(0,0,1024,600);


    so thanks;

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: scaling problem in qpixmap

    QPixmap::scaled() returns a copy of the pixmap that is scaled. It does not alter the original pixmap. You are currently discarding the returned pixmap. Try:
    Qt Code:
    1. QPixmap pixmap("C:/somepixmap.png");
    2. pixmap = pixmap.scaled(1000, 600);
    3. j->addPixmap(pixmap);
    To copy to clipboard, switch view to plain text mode 

    BTW: there's probably no reason to allocate your QPixmap on the heap.

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

    erfan (22nd June 2012)

  4. #3
    Join Date
    Jun 2012
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: scaling problem in qpixmap

    so thanks chris;

Similar Threads

  1. Qwt Log Scaling Problem
    By BettaUseYoNikes in forum Qwt
    Replies: 1
    Last Post: 24th November 2011, 07:20
  2. Translation problem while scaling an object
    By qlands in forum Qt Programming
    Replies: 0
    Last Post: 4th October 2010, 12:04
  3. Pixmap scaling problem
    By tommy in forum Qt Programming
    Replies: 1
    Last Post: 14th May 2009, 17:00
  4. Scaling Painter without scaling the coordinate sytem
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 7th January 2008, 21:30
  5. QPixmap scaling question
    By eric in forum Qt Programming
    Replies: 6
    Last Post: 20th November 2007, 17:40

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.