void MainWindow::on_pushButton_clicked(){ QRect rect(ui->plbl->contentsRect()); QImage sourceImage(rect.size(), QImage::Format_ARGB32_Premultiplied); QPainter painter; painter.begin(&sourceImage); painter.setRenderHint(QPainter::Antialiasing, true); painter.setPen(QPen(QColor(0, 255, 0))); painter.drawLine(0,0,100,100); painter.end(); ui->plbl->setPixmap(QPixmap::fromImage(sourceImage));}