1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
This commit is contained in:
tianduanrui 2018-05-15 20:33:26 +08:00
parent 2aea861992
commit 4faf9a5506
2 changed files with 90 additions and 1 deletions

View File

@ -118,6 +118,76 @@ void QQtWidget::paintEvent ( QPaintEvent* event )
} }
break; break;
case QQTTILEDHEIGHT:
{
p.drawItemPixmap ( rect(), Qt::AlignLeft | Qt::AlignTop,
/*.copy() 切出图片的左上部分使用*/
QPixmap::fromImage ( mImage.copy ( rect() )
.scaledToHeight ( rect().height() )
) );
}
break;
case QQTTILED:
{
p.drawItemPixmap ( rect(), Qt::AlignLeft | Qt::AlignTop,
/*.copy() 切出图片的左上部分使用*/
QPixmap::fromImage ( mImage.copy ( rect() )
.scaled ( rect().width(), rect().height(), Qt::KeepAspectRatio )
) );
}
break;
case QQTZOOMHEIGHT:
{
p.drawItemPixmap ( rect(), Qt::AlignLeft | Qt::AlignTop,
/*不.copy() 切出图片的中间部分使用*/
QPixmap::fromImage ( mImage
.scaled ( mImage.width(), rect().height(), Qt::IgnoreAspectRatio )
) );
}
break;
case QQTZOOM:
{
p.drawItemPixmap ( rect(), Qt::AlignLeft | Qt::AlignTop,
/*不.copy() 切出图片的中间部分使用*/
QPixmap::fromImage ( mImage
.scaled ( rect().width(), rect().height(), Qt::IgnoreAspectRatio )
) );
}
break;
case QQTZOOMWIDTH_KEEPASPECTRATIO:
{
p.drawItemPixmap ( rect(), Qt::AlignLeft | Qt::AlignTop,
/*不.copy() 切出图片的中间部分使用*/
QPixmap::fromImage ( mImage
.scaled ( rect().width(), mImage.height(), Qt::KeepAspectRatio )
) );
}
break;
case QQTZOOMHEIGHT_KEEPASPECTRATIO:
{
p.drawItemPixmap ( rect(), Qt::AlignLeft | Qt::AlignTop,
/*不.copy() 切出图片的中间部分使用*/
QPixmap::fromImage ( mImage
.scaled ( mImage.width(), rect().height(), Qt::KeepAspectRatio )
) );
}
break;
case QQTZOOM_KEEPASPECTRATIO:
{
p.drawItemPixmap ( rect(), Qt::AlignLeft | Qt::AlignTop,
/*不.copy() 切出图片的中间部分使用*/
QPixmap::fromImage ( mImage
.scaled ( rect().width(), rect().height(), Qt::KeepAspectRatio )
) );
}
break;
default: default:
{ {

View File

@ -26,13 +26,32 @@ public:
* , * ,
*/ */
QQTCENTER, QQTCENTER,
/* /**
*
*
* label的效果rect长 * label的效果rect长
**/ **/
QQTTILEDWIDTH, QQTTILEDWIDTH,
QQTTILEDHEIGHT, QQTTILEDHEIGHT,
QQTTILED,
/**
*
*
*/
QQTZOOMWIDTH, QQTZOOMWIDTH,
QQTZOOMHEIGHT, QQTZOOMHEIGHT,
QQTZOOM,
/**
*
*
*/
QQTZOOMWIDTH_KEEPASPECTRATIO,
QQTZOOMHEIGHT_KEEPASPECTRATIO,
QQTZOOM_KEEPASPECTRATIO,
QQTIMAGESTYLEMAX
}; };
void setImageStyle ( ImageStyle style = QQTCENTER ) { m_style = style; } void setImageStyle ( ImageStyle style = QQTCENTER ) { m_style = style; }