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

EGLFS: OpenGL windows cannot be mixed with others.



  • I am using below code to launch my window application(qml file loading) using PyQt5.QQuickView
    @test.py
    import os
    import sys

    from PyQt5.QtCore import QUrl
    from PyQt5.QtGui import QGuiApplication
    from PyQt5.QtQuick import QQuickView
    from PyQt5.QtWebEngine import QtWebEngine

    if name == 'main':
    sys.argv.extend(['-platform', 'eglfs'])
    app = QGuiApplication(sys.argv)
    app.setApplicationName("Hello World")

    QtWebEngine.initialize()
    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(
        QUrl.fromLocalFile(os.path.join(os.path.dirname(__file__), 'myScrollView.qml'))
    
    )
    
    view.show()
    
    sys.exit(app.exec_())
    

    But I am getting an error as below

    @error


    QQuickView does not support using windows as a root item.

    If you wish to create your root window from QML, consider using QQmlApplicationEngine instead.

    EGLFS: OpenGL windows cannot be mixed with others.
    sh: line 1: 10864 Aborted env "PYTHONUNBUFFERED"="1" "PYTHONPATH"="/home/root/.pycharm_helpers/pycharm_matplotlib_backend:/otis:/otis/protocols/generated" "PYCHARM_HOSTED"="1" "JETBRAINS_REMOTE_RUN"="1" "PYCHARM_MATPLOTLIB_PORT"="64833" "PYTHONIOENCODING"="UTF-8" /usr/bin/python3.5 -u /otis/temp/pyqt_file.py

    Process finished with exit code 134


    How to overcome this issue, please help me to resolve this issue.......I am using following in qml file

    @qml file
    import QtQuick 2.0
    import QtQuick.Window 2.1
    import QtQuick.Controls 2.0

    Window{

    }


    Please let me know how to overcome those errors


  • Lifetime Qt Champion

    Hi,

    Either follow the suggestion made:
    @Rohn said in EGLFS: OpenGL windows cannot be mixed with others.:

    If you wish to create your root window from QML, consider using QQmlApplicationEngine instead.

    Or take a look at this example. It's C++ but you can translate it pretty easily in Python.



  • @SGaist No , there is nothing related to my issue....please let me know the way to load the QML file(running application) using mentioned @test.py file using PyQt5 binding


  • Lifetime Qt Champion

    Yes it does since it's showing how to handle a QML file using a Window component.

    Anyway here's how to load properly your Window based QML file:

    engine =  QQmlApplicationEngine()
    engine.load(QUrl.fromLocalFile(os.path.join(os.path.dirname(__file__), 'myScrollView.qml')));
    

    And here's an improved version of your QML object to ensure there's something to show:

     Window{
         visible: true
         width: 512
         height: 300
     
         Text {
             anchors.centerIn: parent
             text: "Hello World!"
         }
     }
    

Log in to reply