After skipping the windows background desktop application, how does QT get the number of monitor connections and home screen index?

zxc0818 1 Reputation point
2023-01-06T01:54:49.16+00:00
  1. When the windows background desktop program is not skipped, QT can call screenCount() to get the number of monitor connections and primaryScreen() to get the home screen index.
  2. After skipping the windows background desktop program (that is, modifying the shell in the registry), restart the computer, the system automatically starts the software program set, skipping the windows desktop, at this time QT can not recognize the number of monitor connections, please tell me what happened? Also, how does QT get the number of monitor connections and the home screen index?

276703-a.png

Windows development | Windows API - Win32
Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C++
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,766 Reputation points
    2023-01-06T14:23:50.087+00:00

    Hello there,

    Got this infromation from an thread which states EnumDisplayMonitors returns monitors in the order defined in the Display Settings, while QGuiApplication::screens always shows primary screen at the first position (actually, QGuiApplication::primaryScreen simply do that: return the first element).

    Looking at the source code, in Windows Qt also uses the EnumDisplayMonitors function but basically moves the primary screen to the first position (it actually inserts in the first position the primary screen, while inserting at the end of the list any other monitor).

    So, the primary screen will be at first position, screens with an index lower than primary screen's will be shifted one position, while the rest will match the index.

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    1 person found this answer helpful.
    0 comments No comments

  2. Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
    2023-01-06T08:12:10.117+00:00

    Hello, @zxc0818 ,

    Welcome to Microsoft Q&A!

    QT is not supported by Microsoft Q&A.
    But you can use

    1. EnumDisplayDevices to obtain information about the display devices in the current session and DISPLAY_DEVICE_PRIMARY_DEVICE indicates the primary desktop.
    2. QueryDisplayConfig to retrieve information about all possible display paths for all display devices, or views, in the current setting and DISPLAYCONFIG_SOURCE_MODE.position that is located at (0, 0) is always the primary source surface. see the QueryDisplayConfig Example.

    Thank you.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.