repaint() on macOS
-
I've got some long running code that needs to notify the user that it is going to take a while.
Here's what I do:
if (zgFWHM.empty()) { ZTRACE_RUNTIME("FWHM interpolation"); message->setText(tr("Interpolating FWHM data. Please be patient.")); message->repaint(); GridData::interpolate(xValues, yValues, fwhmValues, xg, yg, zgFWHM, GridData::InterpolationType::GRID_NNIDW, 10.f); message->setText(""); message->repaint(); ZTRACE_RUNTIME("FWHM interpolation complete"); }This works nicely on Windows and Linux, but on macOS, the message isn't repainted (it's a QLabel).
Is this what I should expect? If not what can I do to ensure the text of the label is updated? Or is it a bug?
Changing the lines that read
message->repaint();to read justrepaint();made no difference.Oops - forgot to mention: This is Qt 6.10.0
UPDATE:
I did manage to "hack" round the problem by adding:
#if defined(Q_OS_MAC) QCoreApplication::processEvents(); #endifafter the first
message->repaint();, but I'm pretty sure I shouldn't need to do that!David
-
Simply don't block the eventloop...
-
C Christian Ehrlicher referenced this topic