PowerModeler/source/maskLayer.cpp

27 lines
648 B
C++
Raw Normal View History

2025-04-21 14:29:20 +08:00
#include "maskLayer.h"
#include <QPainter>
#include <QStyleOption>
MaskLayer::MaskLayer(QWidget *parent)
: QWidget(parent)
{
setObjectName("maskLayer");
setFocusPolicy(Qt::NoFocus);
setAttribute(Qt::WA_TranslucentBackground); // 启用透明背景
setStyleSheet("background:rgba(112,128,144,180);");
hide();
}
MaskLayer::~MaskLayer()
{}
//重写paintEvent触发背景绘制否则实例化对象不显示
void MaskLayer::paintEvent(QPaintEvent *event)
{
QStyleOption opt;
opt.initFrom(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
}