[Qt-interest] asking QPrintPreviewDialog to update

Steven Doerfler sgd-qt at lugaru.com
Mon Feb 15 16:34:12 CET 2010


Steven Doerfler wrote:
> I'd prefer to use QPrintPreviewDialog instead of building my own dialog
> around QPrintPreviewWidget, but I want to use it as a non-modal dialog,
> and signal it it from time to time to update itself with new content. 
> The widget has an updatePreview() slot that works OK for this, but the
> QPrintPreviewDialog dialog has neither a corresponding slot, nor a way
> to access the QPrintPreviewWidget inside it.
>
> Is there some way to send a signal to that slot of the
> QPrintPreviewWidget inside a QPrintPreviewDialog, or some other way to
> do this?
>   
To answer my own question, in case someone else runs into this issue:

Just use QObject::findChild to get a pointer to the dialog's
QPrintPreviewWidget widget, like this

    previewDlg = new PrintPreviewDialog(printer, this);
    QPrintPreviewWidget *w = previewDlg->findChild<QPrintPreviewWidget *>();
    connect(this, SIGNAL(updatePreview()), w, SLOT(updatePreview()));

Steven




More information about the Qt-interest-old mailing list