How do I make an image resize to scale in Qt?

后端 未结 2 1880
情深已故
情深已故 2020-12-01 21:03

I made a class called ImageLabel which extends QLabel. I want it to keep the size ratio of the image that it is displaying no matter how stretched out it is. It works fine w

2条回答
  •  [愿得一人]
    2020-12-01 21:48

    There is no facility built into QLabel to maintain the aspect ratio of the image. Since Qlabel probably has functionality that you don't need, you should subclass QWidget and override the paintEvent() to render the image the way you want.

提交回复
热议问题