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. PrintPreviewDialog issue on 4K monitor
Forum Updated to NodeBB v4.3 + New Features

PrintPreviewDialog issue on 4K monitor

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 1 Posters 326 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.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by
    #1

    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:
    2021-02-14_235401.png

    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.

    1 Reply Last reply
    0
    • Cobra91151C Offline
      Cobra91151C Offline
      Cobra91151
      wrote on last edited by
      #2

      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.
      
      1 Reply Last reply
      0
      • Cobra91151C Offline
        Cobra91151C Offline
        Cobra91151
        wrote on last edited by Cobra91151
        #3

        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 on 4K.

        1 Reply Last reply
        0
        • Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by
          #4

          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 the Fit to width toolbar option and sets a better preview on 4K monitor. It works depending on the screen size. The issue is resolved.

          1 Reply Last reply
          0

          • Login

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