I want redraw one widget without hi's childs, how to use QProcess::sendEvent with QPaintEvent ? I try this, but this doesn't work:
ui->groupBox->setAttribute(Qt::WA_WState_InPaintEvent, true);
ui->groupBox->setAttribute(Qt::WA_WState_InPaintEvent, false);
QPaintEvent *pe = new QPaintEvent(ui->groupBox->rect());
ui->groupBox->setAttribute(Qt::WA_WState_InPaintEvent, true);
QApplication::sendEvent(ui->groupBox, pe);
ui->groupBox->setAttribute(Qt::WA_WState_InPaintEvent, false);
To copy to clipboard, switch view to plain text mode
But this code work and i dont' undrestand why:
pix.fill(Qt::white);
QPainter::setRedirected(ui
->groupBox,
&pix
);
QPainter::restoreRedirected(ui
->groupBox
);
pix.save("file.jpg");
QPaintEvent *pe = new QPaintEvent(ui->groupBox->rect());
QPixmap pix(ui->groupBox->size());
pix.fill(Qt::white);
QPainter::setRedirected(ui->groupBox, &pix);
QApplication::sendEvent(centralWidget(), pe);
QPainter::restoreRedirected(ui->groupBox);
pix.save("file.jpg");
To copy to clipboard, switch view to plain text mode
Bookmarks