leonchiong |
2016-06-27 08:16 |
QPixmap mShadow(":/images/window/window_shadow.png");
this->setAttribute(Qt::WA_TranslucentBackground);
void FWidget::paintEvent(QPaintEvent *) { QPainter painter(this); QRect bottom(5, 136, 200, 7); QRect top(5, 0, 200, 3); QRect left(0, 3, 5, 133); QRect right(205, 3, 5, 133); QRect topRight(205, 0, 5, 3); QRect topLeft(0, 0, 5, 3); QRect bottomLeft(0, 136, 5, 7); QRect bottomRight(205, 136, 5, 7); QRect tBottom(5, this->height() - 7, this->width() - 10, 7); QRect tTop(5, 0, this->width() - 10, 3); QRect tLeft(0, 3, 5, this->height() - 10); QRect tRight(this->width() - 5, 3, 5, this->height() - 10); QRect tTopLeft(0, 0, 5, 3); QRect tTopRight(this->width() - 5, 0, 5, 3); QRect tBottomLeft(0, this->height() - 7, 5, 7); QRect tBottomRight(this->width() - 5, this->height() - 7, 5, 7);
painter.drawPixmap(tBottom, mShadow, bottom); painter.drawPixmap(tTop, mShadow, top); painter.drawPixmap(tLeft, mShadow, left); painter.drawPixmap(tRight, mShadow, right); painter.drawPixmap(tTopRight, mShadow, topRight); painter.drawPixmap(tTopLeft, mShadow, topLeft); painter.drawPixmap(tBottomLeft, mShadow, bottomLeft); painter.drawPixmap(tBottomRight, mShadow, bottomRight); }
贴边框的就用到这三段 |
|