Skip to content

Instantly share code, notes, and snippets.

@0xlitf
Created March 25, 2016 03:36
Show Gist options
  • Select an option

  • Save 0xlitf/273f68259fdd75e0ceb0 to your computer and use it in GitHub Desktop.

Select an option

Save 0xlitf/273f68259fdd75e0ceb0 to your computer and use it in GitHub Desktop.
QLabel显示图片保持缩放比
m_displayer->setPixmap(QPixmap::fromImage(image).scaled(m_displayer->size(), Qt::KeepAspectRatio));
//1、第一个参数应该为label的size,而不是图片的size
//2、不应该设置setScaledContents(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment