PDA

View Full Version : scaling problem in qpixmap



erfan
21st June 2012, 07:39
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;

ChrisW67
21st June 2012, 08:37
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:


QPixmap pixmap("C:/somepixmap.png");
pixmap = pixmap.scaled(1000, 600);
j->addPixmap(pixmap);


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

erfan
21st June 2012, 08:52
so thanks chris;