c++ - QApplication::processEvents not working in Windows -
i working on project presents live data acquired in real-time using qcustomplot plug-in qt. display has black background color, , multiple channels of data colored differently. when taking screenshot, make printer-friendly, background white , data black. thinking of solution this:
- change colors way want manipulating pointers graphical objects
- grab screenshot using qwidget::grab() qpixmap
- change colors normal
this did not work @ first, because system not change colors in time screenshot taken. used qapplication::processevents(), , worked on mac.
however, not work on windows 7 (which required). ideas do?
code:
qsting filelocation = "..."; togglecolors(false); //function toggle colors qapplication::processevents(); qpixmap shot = grab(); togglecolors(true); shot.save(filelocation, "png");
again. works on mac, not windows.
update 1. content of togglecolors include:
if(enable) ui->plot->setbackground(qbrush(qt::black)); else ui->plot->setbackground(qbrush(qt::white)); ui->plot->repaint();
i tried ui->plot->update()
instead.
i not sure problem on windows specifically, recommend calling qwidget::update() on given widget. forces next update re-render itself.
on other hand, i'm not sure why togglecolors() didn't somehow cause happen.
also, ensure qwidget::setupdatesenabled(bool) wasn't set "false."
Comments
Post a Comment