fix:qt6.2 print preview

This commit is contained in:
xiaoyifang 2022-03-29 20:34:41 +08:00
parent 9c6ac4afea
commit 913e4128ca

View file

@ -1705,7 +1705,6 @@ Config::InputPhrase ArticleView::getPhrase() const
void ArticleView::print( QPrinter * printer ) const void ArticleView::print( QPrinter * printer ) const
{ {
#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
QEventLoop loop; QEventLoop loop;
bool result; bool result;
auto printPreview = [ & ]( bool success ) auto printPreview = [ & ]( bool success )
@ -1713,16 +1712,17 @@ void ArticleView::print( QPrinter * printer ) const
result = success; result = success;
loop.quit(); loop.quit();
}; };
#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
ui.definition->page()->print( printer, std::move( printPreview ) ); ui.definition->page()->print( printer, std::move( printPreview ) );
#else
connect( ui.definition, &QWebEngineView::printFinished, &loop, std::move( printPreview ) );
ui.definition->print( printer );
#endif
loop.exec(); loop.exec();
if( !result ) if( !result )
{ {
qDebug() << "print failed"; qDebug() << "print failed";
} }
#else
ui.definition->print( printer );
#endif
} }
void ArticleView::contextMenuRequested( QPoint const & pos ) void ArticleView::contextMenuRequested( QPoint const & pos )