Important: Please read the Qt Code of Conduct -

Detect multiple monitors

  • Hi guys,

    I need to detect multiple monitors on my applictation. My code is already done so I need to do minimal changes on it in order to open the application on a second screen, if it is present.
    I already know about QWdiget and QDesktopWidget, but I need some exemples of how to insert those functions in my code or an alternative to them.

    Thank you in advance,

  • Hi,

    what means "I need to detect multiple monitors"?

    With QDesktopWidget::screenCount() returns the number of screens available on the system

    QDesktopWidget dw;
    if (dw.screenCount() > 1) {
    // Multiple screen
    else {
    // Single screen

    However multiple monitors detecting depends on Window Manager settings (Virtual Desktop, Multiple Desktop, ...)

  • For readers who are finding their way to this topic, QDesktopWidget is depracated. Instead QGuiApplication should be used.

Log in to reply