I want redraw one widget without hi's childs, how to use QProcess::sendEvent with QPaintEvent ? I try this, but this doesn't work:

Qt Code:
  1. QPaintEvent *pe = new QPaintEvent(ui->groupBox->rect());
  2. ui->groupBox->setAttribute(Qt::WA_WState_InPaintEvent, true);
  3. QApplication::sendEvent(ui->groupBox, pe);
  4. 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:

Qt Code:
  1. QPaintEvent *pe = new QPaintEvent(ui->groupBox->rect());
  2. QPixmap pix(ui->groupBox->size());
  3. pix.fill(Qt::white);
  4. QPainter::setRedirected(ui->groupBox, &pix);
  5. QApplication::sendEvent(centralWidget(), pe);
  6. QPainter::restoreRedirected(ui->groupBox);
  7. pix.save("file.jpg");
To copy to clipboard, switch view to plain text mode