QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsDropShadowEffect, 和 QGraphicsOpacityEffect.下面分別介紹它們。ide
QGraphicsBlurEffect
該類用應產生模糊效果,主要函數setBlurRadius(qreal blurRadius),用於控制圖形元素的模糊度,數值越大越模糊。使用該類例子以下函數
QGraphicsBlurEffect *e0 = new QGraphicsBlurEffect(this);
e0->setBlurRadius(0.2);
item[0]->setGraphicsEffect(e1);//item[0] 爲QGraphicsItem指針this
QGraphicsColorizeEffect
該類提供了使用另一種顏色對當前圖形的一種着色功能。主要函數是setColor(QColor)和setStrength (qreal strength),指定了着色和着色強度。使用該類例子以下spa
QGraphicsColorizeEffect *e1 = new QGraphicsColorizeEffect(this);
e1->setColor(QColor(0,0,192));
item[1]->setGraphicsEffect(e1);指針
QGraphicsDropShadowEffect
該類提供了圖形元素的陰影效果,用於增長立體感。主要設置函數有3個,setColor()用於設定陰影的顏色,setBlurRadius()用於設定陰影的模糊度,setOffset (qreal dx,qreal dy)用於設定在哪一個方向產生陰影效果,若是dx爲負數,則陰影在圖形元素的左邊。使用該類例子以下orm
QGraphicsDropShadowEffect *e2 = new QGraphicsDropShadowEffect(this);
e2->setOffset(8,8);
item[2]->setGraphicsEffect(e2);ci
QGraphicsOpacityEffect
該類用於圖形元素的透明效果,主要函數是setOpacity(qreal opacity),用於設置透明度,參數值在0和1.0之間。也能夠設置部分透明效果,須要調用的函數是setOpacityMask (QBrush mask)。使用該類例子以下it
QGraphicsOpacityEffect *e3 = new QGraphicsOpacityEffect(this);
e3->setOpacity(0.7);
item[3]->setGraphicsEffect(e3);class