Display image in Qt to fit label size

前端 未结 7 1297
[愿得一人]
[愿得一人] 2021-02-01 02:53

I already tried several methods on displaying an image on a form, but none of them works how I would like.

I\'ve read many places that the easiest way is to create a la

7条回答
  •  我在风中等你
    2021-02-01 03:31

    Keep a copy of your original pixmap around. Then connect the resized signal to a slot (or override the resizeEvent() function) that implements this :

    lblImage->setPixmap(pixmap.scaled(lblImage->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
    

提交回复
热议问题