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);

  笨办法,行之有效 ~

猜你喜欢

转载自www.cnblogs.com/hbrw/p/10289019.html