QLabel加载图片

原文地址::https://blog.csdn.net/mangobar/article/details/52525555

  1. QRect rect;

  2. MyLabel *pLabel = new MyLabel(ui->scrollAreaWidgetContents);

  3. rect.setX(x);

  4. rect.setY(y);

  5. rect.setWidth(320);

  6. rect.setHeight(320);

  7. pLabel->setGeometry(rect);

  8.  
  9. QString path = QString(":/new/prefix1/1234.jpg")

  10.  
  11. QPixmap px;

  12. px.load(path);

  13. pLabel->setPixmap(px);

  14.  
  15. pLabel->setScaledContents(true);

  16. pLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); //设置外观

  17. pLabel->setScaledContents(true);

  18. pLabel->setVisible(true);

  19.  
  20.  
  21.  
  22. .

猜你喜欢

转载自blog.csdn.net/xqhrs232/article/details/81130665
今日推荐