void Widget::paintEvent(QPaintEvent *) {
QPainter painter(this);
QBrush br;
br.setColor(Qt::blue);
painter.setBrush(br);
// painter.setBrush(QBrush(Qt::blue));
painter.drawRect(10, 10, 50, 50);
}
此代码不起作用,未绘制蓝色矩形。但是注释行工作正常。为什么?