Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QScreen on Windows returns empty manufacturer and model string



  • Hey guys!

    I'm susing Qt 5.10.1 on Win and VS2013.

    QList<QScreen *> screens = QGuiApplication::screens();
    foreach(QScreen *screenInfo, screens)
    {
        qDebug() << "name: " << screenInfo->name();
        qDebug() << "geometry: " << screenInfo->geometry();
        qDebug() << "refreshRate: " << screenInfo->refreshRate();
        qDebug() << "manufacturer: " << screenInfo->manufacturer();
        qDebug() << "size: " << screenInfo->size().width() << screenInfo->size().height();
        qDebug() << "model: " << screenInfo->model();
    }
    

    The code above returns:

    name:  "\\\\.\\DISPLAY1"
    geometry:  QRect(0,0 3840x2160)
    refreshRate:  60
    manufacturer:  ""
    size:  3840 2160
    model:  ""
    
    name:  "\\\\.\\DISPLAY2"
    geometry:  QRect(3840,0 1280x800)
    refreshRate:  60
    manufacturer:  ""
    size:  1280 800
    model:  ""
    

    First screen is my Monitor and second one is a small projector from LG.

    I'd like to include the hardware name like "LG Projector" or "SAMSUNG ..." as well because it is more meaningful to a human. Sure, i can include the Windows.h and the dada but that is not really the point using Qt and platform independent code.

    Am i doing something wrong?

    Thanks!


  • Lifetime Qt Champion

    Hi,

    From a quick look at Qt's sources, it's currently not available on Windows. But if you know the API to use to get that information, you could consider improving the Windows QPA to add support for it.


  • Qt Champions 2019

    ...or at least create a bug report with the appropriate calls :)



  • Well you can do

    DISPLAY_DEVICE dd;
    dd.cb = sizeof(DISPLAY_DEVICE);
    
    DWORD deviceNum = 0;
    while(EnumDisplayDevices(NULL, deviceNum, &dd, 0) )
    {
        // qDebug() << "display: " << QString::fromWCharArray(dd.DeviceName)<< QString::fromWCharArray(dd.DeviceString);
    
        DISPLAY_DEVICE ddmon = {0};
        ddmon.cb = sizeof(DISPLAY_DEVICE);
        DWORD monitorNum = 0;
        while(EnumDisplayDevices(dd.DeviceName, monitorNum, &ddmon, 0))
        {
            qDebug() << "monitor: " << QString::fromWCharArray(ddmon.DeviceName) << QString::fromWCharArray(ddmon.DeviceString);
    
            monitorNum++;
        }
        deviceNum++;
    }
    

    But the result is not perfect. The code above returns

    monitor:  "\\\\.\\DISPLAY1\\Monitor0" "Generic PnP Monitor"
    monitor:  "\\\\.\\DISPLAY2\\Monitor0" "Generic PnP Monitor"
    

    Since "Generic PnP Monitor" is not the results i'm looking for i guess there is not much i can do for now. I guess display1, display2 will do for now.



  • @qDebug Hi! It’s okay for me, i can use this but how can I get this information with python? Do you have any idea? Thanks in advance.


Log in to reply