diff --git a/src/exquisite/irregularwidgets/qqtirregularlabel.cpp b/src/exquisite/irregularwidgets/qqtirregularlabel.cpp index 7af87338..1ca19273 100644 --- a/src/exquisite/irregularwidgets/qqtirregularlabel.cpp +++ b/src/exquisite/irregularwidgets/qqtirregularlabel.cpp @@ -23,6 +23,17 @@ void QQtIrregularLabel::makeMaskWidget ( void ) if ( normalImage.isNull() ) return; //return QQtLabel::resizeEvent ( event ); + if ( hasScaledContents() ) + { + //zoom + setMask ( QPixmap::fromImage ( normalImage + .scaled ( rect().width(), rect().height(), Qt::IgnoreAspectRatio ) + ).mask() ); + + return; + + } + //label的特点, //图片无论如何不会缩放的 !!! //图片无论如何不会变形的 diff --git a/test/testirregularwidgets/mainwindow.cpp b/test/testirregularwidgets/mainwindow.cpp index c4958971..c21072b2 100644 --- a/test/testirregularwidgets/mainwindow.cpp +++ b/test/testirregularwidgets/mainwindow.cpp @@ -116,9 +116,12 @@ MainWindow::MainWindow ( QWidget* parent ) : ui->label_3->installEventFilter ( clicker ); ui->label_8->setPixmap ( QPixmap ( conf_root ( "a1.png" ) ) ); + //ui->label_8->setScaledContents ( true ); + //ui->label_8->setAutoFillBackground ( true ); ui->label_7->setPixmap ( QPixmap ( conf_root ( "a1.png" ) ) ); ui->label_7->installEventFilter ( clicker ); ui->label_7->installEventFilter ( this ); + //ui->label_7->setScaledContents ( true ); QStringList items; items << "Qt::AlignLeft"