1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/test/testwindowattribute/qqtwidgeteffect.cpp
tianduanrui a1202779c2 更新QQtShadowWidget的功能。
可以是主窗口,也可以是子控件。
qqtwindowattribute提供shadow效果只能应用于子控件。
2019-09-01 14:39:26 +08:00

57 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <qqtwidgeteffect.h>
#include <QGraphicsEffect>
#include <qqtanimation.h>
void setShadowEffect ( QWidget* widget )
{
Q_ASSERT ( widget );
/*
* blurRadius 阴影清晰度,越小越清晰
* dx x方向阴影位置和偏移量正值在右方值越大偏移越大
* dy y方向阴影位置和偏移量正值在下方值越大偏移越大
*/
static QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect;
shadow->setBlurRadius ( 10 );
shadow->setColor ( QColor ( 0, 0, 0, 160 ) );
shadow->setOffset ( 5, 5 );
shadow->setEnabled ( true );
widget->setGraphicsEffect ( shadow );
}
void setFadeEffect ( QWidget* widget, quint32 millseconds, qreal startOpacity, qreal endOpacity )
{
Q_ASSERT ( widget );
static QPropertyAnimation* show_animation_ = new QPropertyAnimation ( widget, "windowOpacity" );
show_animation_->setDuration ( millseconds );
show_animation_->setStartValue ( startOpacity );
show_animation_->setEndValue ( endOpacity );
show_animation_->start();
widget->show();
}
void setHighlightTextEffect ( QWidget* widget )
{
Q_ASSERT ( widget );
static QGraphicsDropShadowEffect* shadow_effect = new QGraphicsDropShadowEffect;
shadow_effect->setOffset ( 0, 0 );
shadow_effect->setColor ( Qt::gray );
shadow_effect->setBlurRadius ( 20 );
widget->setGraphicsEffect ( shadow_effect );
}
void setFadeTextEffect ( QWidget* widget, QColor color )
{
Q_ASSERT ( widget );
static QGraphicsColorizeEffect* m_effect = new QGraphicsColorizeEffect;
m_effect->setColor ( color ); //( QColor ( 122, 193, 66 ) );
m_effect->setStrength ( 0 );
m_effect->setEnabled ( true );
widget->setGraphicsEffect ( m_effect );
}