setWindowFlags(Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); QGraphicsDropShadowEffect *bodyShadow = new QGraphicsDropShadowEffect; bodyShadow->setBlurRadius(9.0); bodyShadow->setColor(QColor(0, 0, 0, 160)); bodyShadow->setOffset(4.0); ui->centralWidget->setGraphicsEffect(bodyShadow);
ShadowWindow::ShadowWindow(QWidget *parent) : QWidget(parent){ setAttribute(Qt::WA_TranslucentBackground); m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(9,9,9,9); m_layout->setSpacing(0); m_shadowPixmap.load(":/image/resources/image/shadow.png");}void ShadowWindow::paintEvent(QPaintEvent *event){ QPainter painter(this); painter.drawPixmap(0,0,m_shadowPixmap,0,0,14,14); painter.drawPixmap(14,0,width() - 28,14,m_shadowPixmap,14,0,1,14); painter.drawPixmap(width() - 14,0,m_shadowPixmap,15,0,14,14); painter.drawPixmap(0,14,14,height() - 28, m_shadowPixmap, 0, 14,14,1); painter.drawPixmap(0,height() - 14,m_shadowPixmap,0,15,14,14); painter.drawPixmap(width() - 14,14,14,height() - 28, m_shadowPixmap, 15,14,14,1); painter.drawPixmap(width() - 14,height() - 14,m_shadowPixmap,15,15,14,14); painter.drawPixmap(14,height() - 14,width() - 28,14, m_shadowPixmap, 15,15,1,14); QWidget::paintEvent(event);}