Quote Originally Posted by ashukla View Post
Qt Code:
  1. #include <QApplication>
  2. #include <QPixmap>
  3. #include <QLabel>
  4. int main (int argc, char **argv)
  5. {
  6.  
  7. QApplication app(argc,argv);
  8. QLabel lab(0,Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
  9. QPixmap p("plane.jpg");
  10.  
  11.  
  12. lab.setText("Hello");
  13. lab.show();
  14. lab.resize(300,200);
  15. p=p.scaled ( lab.width(),lab.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
  16. lab.setPixmap(p);
  17. return app.exec();
  18. }
To copy to clipboard, switch view to plain text mode 
Dear JPN!
Now, You should happy for above. Give any suggestion with free mind.
Oooh, can I nitpick too?
You need an #include <QApplication> for this to compile
You don't need to #include <QPixmap> as that gets pulled in by QLabel
Setting "hello" as the labels text does nothing since it will just show the image
Calling show() on the label doesn't actually show the label until control returns to the event loop, so theoretically width() and height() won't work properly (although it seems that they do anyway here)
You don't need to scale the image yourself.

Here's how I would do it.

Qt Code:
  1. #include <QLabel>
  2. #include <QApplication>
  3. int main (int argc, char **argv) {
  4. QApplication app(argc,argv);
  5. QLabel lab(0,Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
  6. lab.resize(300,200);
  7. lab.setPixmap(QPixmap("plane.png"));
  8. lab.setScaledContents(true);
  9. lab.show();
  10. return app.exec();
  11. }
To copy to clipboard, switch view to plain text mode 

Any more improvements possible?