The interessting thing is:
1.) I have a rendered "Plot", i can see the "Plot" in preview window
2.) Now i click on the "Report", the "Report" will be rendered but not shown
3). The orientation is landscape, when i now switch to portrait or click again on landscape i can see the updated preview, my "Report"
Could this be a workaround to trigger the action?
QList<QToolBar *> qlPreviewToolbars = pPreview->findChildren<QToolBar *>();
QToolBar *previewToolbar
= qlPreviewToolbars.
at(0);
previewActions = previewToolbar->actions();
QList<QToolBar *> qlPreviewToolbars = pPreview->findChildren<QToolBar *>();
QToolBar *previewToolbar = qlPreviewToolbars.at(0);
previewActions = previewToolbar->actions();
To copy to clipboard, switch view to plain text mode
void PrintPreview
::render(QPrinter *printer
) {
qDebug() << Q_FUNC_INFO;
if( checkPlot.isChecked() )
renderPlot( printer );
if( checkReport.isChecked() )
renderReport( printer );
// action for
previewActions.at(7)->trigger(); // now my app crashes at this point?
}
void PrintPreview::render(QPrinter *printer)
{
qDebug() << Q_FUNC_INFO;
if( checkPlot.isChecked() )
renderPlot( printer );
if( checkReport.isChecked() )
renderReport( printer );
// action for
previewActions.at(7)->trigger(); // now my app crashes at this point?
}
To copy to clipboard, switch view to plain text mode
Added after 23 minutes:
I found workaround for this:
// constructor
connect( pPreview,
SIGNAL(paintRequested
(QPrinter*)),
this,
SLOT(render
(QPrinter*)));
connect( &checkPlot, SIGNAL(released()), this, SLOT(render()));
connect( &checkReport, SIGNAL(released()), this, SLOT(render()));
d_data->styleChanged = false;
void PrintPreview::render()
{
d_data->styleChanged = true;
emit pPreview->paintRequested( printer );
}
void PrintPreview
::render(QPrinter *printer
) {
if(!d_data->styleChanged)
{
if( checkPlot.isChecked() )
renderPlot( printer );
if( checkReport.isChecked() )
renderReport( printer );
}
else
{
d_data->styleChanged = false;
// Workaround
// when orientation is landscape, trigger again landscape (this updates preview)
// when orientation is portait, trigger again portrait (this updates preview)
if(printer
->orientation
() == QPrinter::Landscape ) previewActions.at(8)->trigger(); // if landscape, trigger action landscape again and this emits later a paintRequest
else
previewActions.at(7)->trigger(); // if portrait, trigger action portrait again and this emits later a paintRequest
}
}
// constructor
connect( pPreview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(render(QPrinter*)));
connect( &checkPlot, SIGNAL(released()), this, SLOT(render()));
connect( &checkReport, SIGNAL(released()), this, SLOT(render()));
d_data->styleChanged = false;
void PrintPreview::render()
{
d_data->styleChanged = true;
emit pPreview->paintRequested( printer );
}
void PrintPreview::render(QPrinter *printer)
{
if(!d_data->styleChanged)
{
if( checkPlot.isChecked() )
renderPlot( printer );
if( checkReport.isChecked() )
renderReport( printer );
}
else
{
d_data->styleChanged = false;
// Workaround
// when orientation is landscape, trigger again landscape (this updates preview)
// when orientation is portait, trigger again portrait (this updates preview)
if(printer->orientation() == QPrinter::Landscape )
previewActions.at(8)->trigger(); // if landscape, trigger action landscape again and this emits later a paintRequest
else
previewActions.at(7)->trigger(); // if portrait, trigger action portrait again and this emits later a paintRequest
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks