setGraphicsEffect(new QGraphicsBlurEffect);
C++ (Qt)Q_GUI_EXPORT void qt_blurImage( QPainter* p, QImage& blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0 ); class BlurRectItem : public QGraphicsRectItem{public: BlurRectItem( const QRectF& rect ) : QGraphicsRectItem( rect ) , radius_( 5 ) , in_grab_( false ) { setZValue( 10000 ); setFlag( ItemIsMovable ); setCursor( Qt::OpenHandCursor ); } void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 ) { if( in_grab_ ) return; in_grab_ = true; QImage img( rect().size().toSize(), QImage::Format_RGB32 ); QPainter p( &img ); p.eraseRect( rect() ); p.setRenderHint( QPainter::Antialiasing ); scene()->render( &p, QRectF(), sceneBoundingRect() ); p.end(); in_grab_ = false; painter->save(); qt_blurImage( painter, img, radius_, true, false ); painter->restore(); painter->drawRect( rect() ); } qreal blurRadius() const { return radius_; } void setBlurRadius( qreal r ) { radius_ = r; } private: bool in_grab_; qreal radius_;};
Q_GUI_EXPORT void qt_blurImage( QPainter* p, QImage& blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0 );