Thank you.Your suggestion worked.
****in case anyone's having the same problem as I was having,I am pasting the working code below********
int count =0; //count keeps track of the number of times you click thw rotate button
void ImageViewer::rotate() //slot which is called on clicking rotate
{
count++;
QPixmap pm
=QPixmap(fileName
);
//fileName is the picture that you are displaying mat.rotate((90*count)%360); //rotation operation
if(count%2==1) //code which rotates pic by 90,180,360 depending on the number
//of times you click 'rotate'
{
mat.scale((double)420/pm.width(),(double)750/pm.height());
}
else
mat.scale((double)750/pm.width(),(double)420/pm.height());
QPixmap pm1
=pm.
transformed(mat
);
//saving the changed QPixmap in a new QPixmap imageLabel->setPixmap(pm1); //setting changed Pixmap on the label
}
int count =0; //count keeps track of the number of times you click thw rotate button
void ImageViewer::rotate() //slot which is called on clicking rotate
{
count++;
QPixmap pm=QPixmap(fileName); //fileName is the picture that you are displaying
QMatrix mat;
mat.rotate((90*count)%360); //rotation operation
if(count%2==1) //code which rotates pic by 90,180,360 depending on the number
//of times you click 'rotate'
{
mat.scale((double)420/pm.width(),(double)750/pm.height());
}
else
mat.scale((double)750/pm.width(),(double)420/pm.height());
QPixmap pm1=pm.transformed(mat); //saving the changed QPixmap in a new QPixmap
imageLabel->setPixmap(pm1); //setting changed Pixmap on the label
}
To copy to clipboard, switch view to plain text mode
Bookmarks