【问题标题】:How to set QLabel's size to that of the image in its pixmap?如何将 QLabel 的大小设置为其像素图中的图像大小?
【发布时间】:2011-05-01 22:29:38
【问题描述】:

我在我的应用程序中使用 QT,最后使用 QLabel 来显示图像。但是,它显示为裁剪。 QLabel 的大小如何设置为其像素图之一?如果像素图发生变化,它怎么会发生变化?

【问题讨论】:

    标签: c++ image qt


    【解决方案1】:
    // Call this function whenever you want to change the label's pixmap
    void SetPixmapLabel(QLabel * myLabel, const QPixmap & pixmap)
    {
       myLabel->setPixmap(pixmap);
       myLabel->setFixedSize(pixmap.size());
    }
    

    【讨论】:

      猜你喜欢
      • 2014-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-13
      • 2018-08-19
      • 2014-03-31
      • 2011-05-16
      • 1970-01-01
      相关资源
      最近更新 更多