Blank screen on Android devices. Works on emulator



  • Hi,

    I am getting a blank screen on S3 (Android 4.3) and S4 (Android 4.4) Android devices, however it seems to work just fine on the emulator.

    Tried out some of the samples, they also have issues rendering properly, for example the Maroon sample only uses half of the screen.

    I am using Qt 5.3.2.

    Does anyone have an idea what might be the cause? The solution seems to be rewrite the UI in Java :\



  • Without any details about your project, it's impossible to guess what can be your problem.
    Please, share some details.

    For what concerns the samples, you should take as a guidelines for developing not as production products. This means, that maybe the Maroon sample run in a fixed screen size just to show you how to create a game simplifying the code removing that code needed for scaling and adapting to any mobile screen.



  • My startup code:

    @int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    qmlRegisterType<MapWidget>("MapWidget", 1,0, "MapWidget");

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
    
    return app.exec();
    

    }@

    and my QML code. The MapWidget is a derived class from QQuickPaintedItem, but I already proved it is not to blame, as I get the same outcome, if I remove it from the QML file.

    @import QtQuick 2.2
    import QtQuick.Controls 1.2
    import QtQuick.Dialogs 1.1
    import MapWidget 1.0

    ApplicationWindow {
    visible: true
    title: qsTr("A* search demo")

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("Open...")
                onTriggered: fileDialog.setVisible(true);
            }
            MenuItem {
                text: qsTr("Run")
                onTriggered: mapWnd.startSearch();
            }
            MenuSeparator {
    
            }
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
        }
    }
    
    FileDialog {
        id: fileDialog
        title: qsTr("Please choose a map file")
        nameFilters: [ qsTr("Map files (*.txt)") ]
        onAccepted: {
            console.log("You chose: " + fileDialog.fileUrl)
            mapWnd.loadMap(fileDialog.fileUrl);
            mapWnd.update();
        }
    }
    
    MapWidget {
        id: mapWnd
        startPos: "20,20"
        endPos: "60,60"
        anchors.fill: parent
        focus:true
        Keys.onPressed: {
            if (event.key === Qt.Key_G)
            {
                showGrid = true
                update()
            }
            else if (event.key === Qt.Key_H)
            {
                showGrid = false
                update()
            }
        }
    }
    

    }@



  • Ok, one things that you can try is to set a fixed dimension of the ApplicationWindow setting width and height properties.
    Maybe, one problem on the real device is that the ApplicationWindow does not goes full screen automatically.

    In my apps, I usually use QQuickView that has an esplicity method for resizing the root item:
    @
    QQuickView viewer;
    viewer.setResizeMode( QQuickView::SizeRootObjectToView );
    viewer.setSource( backend->commonPath()+"/qml/splash.qml" );
    viewer.show();
    @

    Give a try and let me know how is going.



  • Actually I had width and height configured, just removed them when I came to the conclusion it didn't had any visible effect.

    It doesn't work. It seems I am forced to rewrite my QML to be able to use a QQuickView instead.

    bq. QQuickView only supports loading of root objects that derive from QQuickItem.
    If your example is using QML 2, (such as qmlscene) and the .qml file you
    loaded has 'import QtQuick 1.0' or 'import Qt 4.7', this error will occur.
    To load files with 'import QtQuick 1.0' or 'import Qt 4.7', use the
    QDeclarativeView class in the Qt Quick 1 module.

    Does this force me to do manually the work provided by ApplicationWindow?

    Thanks for the support.



  • Just had another attempt at it.

    This plain QML file

    @import QtQuick 2.2
    import QtQuick.Controls 1.2
    import QtQuick.Dialogs 1.1

    ApplicationWindow {
    visible: true
    width: 640
    height: 400
    title: qsTr("A* search demo")

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("Open...")
            }
            MenuItem {
                text: qsTr("Run")
            }
            MenuSeparator {
    
            }
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
        }
    }
    

    }@

    Just dies on the device, while working on the emulator.

    bq. I/Adreno-EGL(12125): <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_KK_2.7_RB1.04.04.02.007.050_msm8960_refs/tags/AU_LINUX_ANDROID_KK_2.7_RB1.04.04.02.007.050__release_AU ()
    I/Adreno-EGL(12125): OpenGL ES Shader Compiler Version: 17.01.12.SPL
    I/Adreno-EGL(12125): Build Date: 03/28/14 Fri
    I/Adreno-EGL(12125): Local Branch:
    I/Adreno-EGL(12125): Remote Branch: refs/tags/AU_LINUX_ANDROID_KK_2.7_RB1.04.04.02.007.050
    I/Adreno-EGL(12125): Local Patches: NONE
    I/Adreno-EGL(12125): Reconstruct Branch: NOTHING
    D/OpenGLRenderer(12125): Enabling debug mode 0
    D/OpenGLRenderer(12125): GL error from OpenGLRenderer: 0x502
    E/OpenGLRenderer(12125): GL_INVALID_OPERATION
    D/OpenGLRenderer(12125): GL error from OpenGLRenderer: 0x502
    E/OpenGLRenderer(12125): GL_INVALID_OPERATION
    D/OpenGLRenderer(12125): GL error from OpenGLRenderer: 0x502
    E/OpenGLRenderer(12125): GL_INVALID_OPERATION

    I give up. :(

    Thanks again for the support.



  • Qt 5.4 fixes this issue.


Log in to reply
 

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