[SOLVED] QPrintPreviewDialog: problem with updating preview
-
wrote on 28 Jan 2014, 08:14 last edited by
I added the printer selector (QComboBox-based) into standard QPrintPreviewDialog to allow user to select required printer. As soon as selection is changed, dialog updates preview of pages by QPrintPreviewWidget::updatePreview() method:
@ QList<QPrintPreviewWidget*> list = dialog->findChildren<QPrintPreviewWidget*>();
if (list.isEmpty())
return;QPrintPreviewWidget *preview = list.first(); preview->updatePreview();@
But I'm faced by the following problem here. The updatePreview() method crashes the application.
I found out, that in my slot, connected to QPrintPreviewDialog::paintRequested() signal, there are 2 constructions, which causes the problem.
The first of them uses QEventLoop::exec() method. You can find more details here http://qt-project.org/forums/viewthread/35615/
The second one uses QProgressDialog::setValue(int) method.
If I disable both of them the problem disappears. It's really strange, because when QPrintPreviewDialog is shown at the first time, the mentioned slot works properly, but when updatePreview method is called in already shown dialog, the problem occurs.
Any ideas?
Thanks in advance.
P.S. Qt v4.7.4, Windows 7
-
wrote on 28 Jan 2014, 08:31 last edited by
Test it on an another version.
-
wrote on 28 Jan 2014, 09:12 last edited by
As a workaround solution I replaced this line:
@preview->updatePreview();@
with these ones:
@preview->hide();
preview->updatePreview();
preview->show();@I.e. I hide QPrintPreviewWidget to block its event loop.
1/3