PowerModeler/source/maskLayer.cpp

27 lines
648 B
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 "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);
}