how to get the maximum size the label can occupy
how to get the maximum size the label can occupy
To copy to clipboard, switch view to plain text mode
Use maximumSize() and setMaximumSize() for this.
And use this code for your problem;
#include <QtGui>
int main (int argc, char **argv)
{
QPixmap p1
(p
->scaled
( lab
->width
(),lab
->height
(), Qt
::IgnoreAspectRatio, Qt
::SmoothTransformation ));
lab->setPixmap(p1);
lab->show();
lab->adjustSize();
w.show();
w.resize(300,200);
return app.exec();
}
#include <QtGui>
int main (int argc, char **argv)
{
QApplication app(argc,argv);
QWidget w;
QLabel *lab=new QLabel(&w);
QPixmap *p=new QPixmap("plane.jpg");
QPixmap p1(p->scaled ( lab->width(),lab->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ));
lab->setPixmap(p1);
lab->show();
lab->adjustSize();
w.show();
w.resize(300,200);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks