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

Adapt a QML part to OpenGL abilities



  • Hello,
    I'm working on an application intended to be used only in Linux platform, but without specification about graphical configuration.
    A user reported me a stop of the application because its graphical card is Intel 82852/855GM, thus without OpenGL 2 abilities. The error reported is:
    QOpenGLShader: could not create shader
    I presume this is because I use LinearGradient.
    What I want to try is to detect if the platform is OpenGL2 able or not, and if not don't use LinearGradient.
    I tried some log in Qml:
    console.log(GraphicsInfo.majorVersion, GraphicsInfo.minorVersion)
    but which reports me "undefined undefined"
    Documentation about GraphicsInfo says: "If the item to which the properties are attached is not currently associated with any window, the properties are set to default values. "
    I don't understand to which item and properties it is referred to.

    Thanks



  • import QtQuick 2.12
    import QtQuick.Controls 2.12
    
    ApplicationWindow {
        visible: true
    
        MouseArea {
            anchors.fill: parent
            onClicked: console.log(GraphicsInfo.majorVersion, GraphicsInfo.minorVersion)
        }
    }
    


  • @Nifiro
    Thanks,
    Indeed, this is working with qmlscene.
    Thus I have to find why this is not working for my application.
    I have Qt 5.9, but I don't think this could be a problem.
    I don't have QtQuick 2.12, but tried with QtQuick 2.8 and this works.
    I tried also QtQuick.Controls 1.4 with no problem.
    My application is launched from Python 3 using PyQt, QGuiApplication and QQuickView. When I replace the QML file with the one you provided and I replace ApplicationWindow with Rectangle, this works too. I get 3 and 0 respectively.
    I have now included outputs for GraphicsInfo.majorVersion and minor, what I get is variable :/
    One time, I get 3.0, another time, I get 2.0 (same application)
    Why is this changing ? Is not this information about system ability?



  • I continue my investigations.
    I passed the test example from Nifiro to the guy who got the problems.
    He got now:

    QT_LOGGING_RULES=qml=true qmlscene test.qml
    QOpenGLShader: could not create shader
    Segmentation fault (core dumped)
    

    Thus I presume that the error occurs before I can test the version (at import or at ApplicationWindow?), which is useless.
    This says also that my first plan to adapt instructions in QML is void :/


Log in to reply