#include "pixbmpshowdialog.h" #include "ui_pixbmpshowdialog.h" #include PixbmpShowDialog::PixbmpShowDialog(QWidget *parent) : BaseDlg(parent), ui(new Ui::PixbmpShowDialog) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); } PixbmpShowDialog::~PixbmpShowDialog() { delete ui; } void PixbmpShowDialog::ResizeByPixmap(int w,int h) { m_iWidth=w; m_iHeight=h; int iWidth=w; int iHeight=h; if(iWidthresize(iWidth,iHeight); else { if(iWidth>iHeight) this->resize(rect().height()*iWidth/iHeight,rect().height()); else this->resize(rect().width(),rect().width()*iHeight/iWidth); } } void PixbmpShowDialog::paintEvent(QPaintEvent * event) { Q_UNUSED(event); QPainter painter(this); //painter.eraseRect(rect()); // painter.scale(m_PixMap.width(), m_PixMap.height()); QRectF sourceRt(0,0,m_iWidth,m_iHeight); painter.drawPixmap(rect(), m_PixMap,sourceRt); }