Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QPrintPreviewDialog: problem with updating preview
Forum Update on Monday, May 27th 2025

[SOLVED] QPrintPreviewDialog: problem with updating preview

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fundaev
    wrote on 28 Jan 2014, 08:14 last edited by
    #1

    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

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pozitiffcat
      wrote on 28 Jan 2014, 08:31 last edited by
      #2

      Test it on an another version.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fundaev
        wrote on 28 Jan 2014, 09:12 last edited by
        #3

        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 Reply Last reply
        0

        1/3

        28 Jan 2014, 08:14

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved