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. QScreen of multi-monitor cannot be returned.
QtWS25 Last Chance

QScreen of multi-monitor cannot be returned.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 5 Posters 581 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.
  • H Offline
    H Offline
    Hugh_Zen
    wrote on last edited by Chris Kawa
    #1

    I'm developing a Qt app on dual monitors and using 6.2.
    QApplication screens() always returns a single Screen value.
    It has the geometry value of the secondary monitor and does not get the information of the primary monitor.

    #include "mainwindow.h"
    
    #include <QApplication>
    #include <QScreen>
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        qDebug().noquote() << "Screen size:             : " << QApplication::screens().size();
        foreach(QScreen *screen, QApplication::screens()) {
            qDebug().noquote() << "Name             : " << screen->name();
            qDebug().noquote() << "DevicePixelRatio : " << screen->devicePixelRatio();
            qDebug().noquote() << "Width            : " << screen->geometry().width();
            qDebug().noquote() << "Height           : " << screen->geometry().height();
            qDebug().noquote() << "Size             : " << screen->geometry().size();
            qDebug().noquote() << "Geom             : " << screen->geometry();
        }
    
    
        qDebug().noquote() << "Primary screen Geom             : " << QApplication::primaryScreen()->geometry();
        return a.exec();
    }
    

    result

    [15704] Screen size: : 1
    [15704] Name : DELL U2722D
    [15704] DevicePixelRatio : 1
    [15704] Width : 2560
    [15704] Height : 1440
    [15704] Size : QSize(2560, 1440)
    [15704] Geom : QRect(2560,0 2560x1440)
    [15704] Primary screen Geom : QRect(2560,0 2560x1440)

    On the other computer, the QScreen on the dual monitor returns normally without any problems.

    Any solution?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are they both desktop machines ?
      What are the differences between them ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by Chris Kawa
        #3

        Maybe a silly question, but are the monitors in extend or duplicate mode? Duplicate would return a single entry.

        1 Reply Last reply
        2
        • G Offline
          G Offline
          Guitronic
          wrote on last edited by
          #4

          Hi,
          same in Qt 6.2 with Windows 10.
          Is there a solution?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Shatyuka
            wrote on last edited by
            #5

            Same here with Qt 6.2.4 Windows 11, works fine with Qt 6.4.

            Shame of LTS.

            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