Qt 圆角方案

  重写 paintEvent :

  

    Q_UNUSED(event)

    QPainter p(this);
    p.setPen(Qt::NoPen);
    p.setBrush(QBrush(QColor(0, 0, 0, 180)));
    p.setRenderHint(QPainter::Antialiasing);
    p.drawRoundedRect(0, 0, width() - 1, height() - 1, 20, 20);

  noPen 就不会有边框的黑色点点了,还阔以 ~


  另外,子窗口居中显示:
  
  cicle->move(this->width() / 2 - cicle->width() / 2, this->height() / 2 - cicle->height() / 2);

  笨办法,行之有效 ~
posted @ 2019-01-18 17:48  Mtr1994  阅读(272)  评论(0编辑  收藏  举报