修复遮罩层的一些问题
parent
df324da102
commit
231407dff1
11
Qss.cpp
11
Qss.cpp
|
@ -1662,7 +1662,7 @@ QssMaskWidget::QssMaskWidget(QWidget *parent)
|
||||||
parent->installEventFilter(this);
|
parent->installEventFilter(this);
|
||||||
mParent = parent;
|
mParent = parent;
|
||||||
}
|
}
|
||||||
|
this->installEventFilter(this);
|
||||||
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::Tool);// 无边框 无任务栏
|
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::Tool);// 无边框 无任务栏
|
||||||
setAttribute(Qt::WA_TranslucentBackground, true); // 背景透明
|
setAttribute(Qt::WA_TranslucentBackground, true); // 背景透明
|
||||||
|
|
||||||
|
@ -1677,21 +1677,24 @@ QssMaskWidget::~QssMaskWidget()
|
||||||
bool QssMaskWidget::eventFilter(QObject *obj, QEvent *ev)
|
bool QssMaskWidget::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if(obj != this){
|
if(obj != this){
|
||||||
qDebug()<<obj->objectName()<<ev;
|
|
||||||
if(mParent != nullptr){
|
if(mParent != nullptr){
|
||||||
if(mParent->parentWidget() != nullptr){
|
if(mParent->parentWidget() != nullptr){
|
||||||
qDebug()<<mParent->parentWidget()->geometry();
|
|
||||||
this->move(mParent->parentWidget()->geometry().x(),mParent->parentWidget()->geometry().y());
|
this->move(mParent->parentWidget()->geometry().x(),mParent->parentWidget()->geometry().y());
|
||||||
|
this->show();
|
||||||
|
this->raise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(obj == this){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QssMaskWidget::paintEvent(QPaintEvent *event)
|
void QssMaskWidget::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter paint(this);
|
QPainter paint(this);
|
||||||
paint.begin(this);
|
|
||||||
auto kBackgroundColor = QColor(1, 1, 1);
|
auto kBackgroundColor = QColor(1, 1, 1);
|
||||||
kBackgroundColor.setAlpha(0.1 * 255);// 透明度为0
|
kBackgroundColor.setAlpha(0.1 * 255);// 透明度为0
|
||||||
paint.setRenderHint(QPainter::Antialiasing, true);
|
paint.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
Loading…
Reference in New Issue