Qt4 How to draw inside a widget?

后端 未结 2 1611
囚心锁ツ
囚心锁ツ 2021-02-04 05:57

Qt4, QtCreator

I am trying to draw inside Widget:

void Widget::on_pushButton_clicked()
{
    QPainter painter;

    painter.begin(ui->label);

    QRe         


        
2条回答
  •  心在旅途
    2021-02-04 06:29

    If you overwrite the paint-method as described by Arnold Spence, you should call the parent's paintEvent or you end up with a widget that only shows your rectangle on a white background.

提交回复
热议问题