[Solved] QML; Screen return nothing



  • Hello! I'm trying to create qml application for several screens. For that i use Screen qml object but it looks broken for me.
    This lines
    console.log(Screen);
    console.log(Screen.desktopAvailableHeight);
    console.log(Screen.desktopAvailableWidth);
    console.log(Screen.devicePixelRatio);
    console.log(Screen.height);
    console.log(Screen.name);
    console.log(Screen.orientation);
    console.log(Screen.orientationUpdateMask);
    console.log(Screen.pixelDensity);
    console.log(Screen.primaryOrientation);
    console.log(Screen.width);
    return me
    qml: QQuickScreenAttached(0x26a82c0)
    qml: 0
    qml: 0
    qml: 1
    qml: 0
    qml:
    qml: 0
    qml: 0
    qml: 0
    qml: 0
    qml: 0
    on desktop and android devices.
    There are any ways for me help you to help me?



  • Hi
    Are you accessing Screen inside an Item or Window type? If not, that may be the problem.
    The following sample works:

    ApplicationWindow {
         id: window    
         visible: true
         width: 480; height: 800
    
         Component.onCompleted: {
              console.debug("Screen density", Screen.pixelDensity);
         }
    }


  • Thanks a lot! I put it in AppWindow object and it works.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.