From 17fb3bf430780930074aca3a7e4e2dd323f3ba32 Mon Sep 17 00:00:00 2001 From: liuminghang Date: Thu, 24 Jun 2021 16:51:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3bug85090?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 使用看图的适应图片的策略 Log: 与图片显示有关 Bug: https://pms.uniontech.com/zentao/bug-view-85090.html Change-Id: I2d6ac4ae04af90b8b36ee56e9b0e318a16649131 --- src/mainwidget.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mainwidget.cpp b/src/mainwidget.cpp index b903a1f..9306b41 100644 --- a/src/mainwidget.cpp +++ b/src/mainwidget.cpp @@ -193,6 +193,7 @@ void MainWidget::setupUi(QWidget *Widget) m_pwidget->setFixedSize(this->width(), this->height() - 23); m_pwidget->move(0, 0); + } void MainWidget::setupConnect() @@ -300,7 +301,16 @@ void MainWidget::openImage(const QImage &img, const QString &name) if (m_imageview) { m_imageview->openFilterImage(img); QTimer::singleShot(100, [ = ] { - m_imageview->fitWindow(); + //分辨率大于window的采用适应窗口,没超过,则适应图片 + QRect rect1 = m_imageview->image().rect(); + if ((rect1.width() >= m_imageview->width() || rect1.height() >= m_imageview->height() - 150) && m_imageview->width() > 0 && + height() > 0) + { + m_imageview->fitWindow(); + } else + { + m_imageview->fitImage(); + } }); m_imgName = name; }