PrintPreviewDialog issue on 4K monitor
-
Hello!
I have added the print preview feature to my program. The problem is, it displays the preview document not well on the screen resolutions above the
1920x1080
.Example:
Code:
QFont docFont; docFont.setPointSize(14); QTextDocument *textDoc = new QTextDocument(this); textDoc->setDefaultFont(docFont); textDoc->setPlainText(getHardwareData());
Is there any hint/font to make it look well on all screens resolutions on
Windows
? Thank you. -
During a debugging process I have found the following issues:
QWindowsMultiFontEngine::loadEngine: CreateFontFromLOGFONT failed for "Courier": error 0x88985002 : Indicates the specified font does not exist. QWindowsMultiFontEngine::loadEngine: CreateFontFromLOGFONT failed for "Courier": error 0x88985002 : Indicates the specified font does not exist.
-
I have fixed the
QWindowsMultiFontEngine::loadEngine: CreateFontFromLOGFONT failed for "Courier"
issue. The problem was caused by a Unicode character in Peripheral data. Now, the only thing left is to make it look better on4K
. -
I have found some hack to get the toolbar actions from a print preview dialog. By adding some additional logic it fixed the issue.
QList<QToolBar*> toolbarList = printPreviewDlg->findChildren<QToolBar*>(); if (!toolbarList.isEmpty()) { if (screenSize.width() > 1920 && screenSize.height() > 1080) { toolbarList.first()->actions().at(0)->activate(QAction::Trigger); } else { toolbarList.first()->actions().at(1)->activate(QAction::Trigger); } }
To detect the screen size I use the native
Win API
methods. Now, it automatically triggers theFit to width
toolbar option and sets a better preview on4K
monitor. It works depending on the screen size. The issue is resolved.