当前位置:   article > 正文

QT笔记-Label控件显示图片_qt用什么控件显示图片比较好

qt用什么控件显示图片比较好

 1、Label控件动态显示图片

  1. //动态显示图片1
  2. int DeviceEdit::OnLensPic(bool checked)
  3. {
  4. AfCd::cd();
  5. QImage img;
  6. img.load("UI/lens.bmp");
  7. QImage imgScaled;
  8. imgScaled = img.scaled(ui.labelPic->size(), Qt::KeepAspectRatio);//默认保持原图的宽高比 以label大小为大小
  9. ui.labelPic->setPixmap(QPixmap::fromImage(imgScaled));
  10. return 0;
  11. }
  12. //动态显示图片1-无锯齿
  13. int DeviceEdit::OnLensPic(bool checked)
  14. {
  15. string strpath = m_strPathImages + "\\menu.png";
  16. ui.label_shengchan->setFixedSize(45, 45);
  17. ui.label_shengchan->setScaledContents(true);
  18. QPixmap topMsgIcon(GBK::ToUnicode(strpath));
  19. ui.label_shengchan->setPixmap(topMsgIcon);
  20. }

2、 Label控件设计界面显示图片

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/708971
推荐阅读
相关标签
  

闽ICP备14008679号