Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML application not rendered correctly in Qt Wayland Compositor examples

QML application not rendered correctly in Qt Wayland Compositor examples

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    robgu
    wrote on last edited by
    #1

    Hello,

    I'm trying to get familiar with QML's Wayland compositor examples.
    For that I have cross-compiled Qt 6.5.3 with a provided example (analogclock) for my Raspberry Pi running on Ubuntu 22.04 to make sure all is fine. I also compiled the "minimal-qml" compositor example and installed Weston for having a reference. Then I made a very simple QML app (code below).

    First step was to check whether the compilation is fine: both analogclock and my QML applications run smoothly in gnome desktop on Raspberry Pi.
    Then I switched to tty and started Weston compositor. Again both applications run smoothly when started with command

    ./application_name --platform wayland
    

    Here's how my app looks like in Weston:
    qmlapp_in_weston.jpg
    Finally, still in tty, I started the minimal-qml example compositor:

    ./minimal-qml --platform eglfs
    

    When started as mentioned above, the analogclock application is fine, but my QML application does not render correctly:
    qmlapp_in_minimal-qml.jpg

    The black dots are the text, and I suppose that the grey areas have something to do with the window decorations (title bar, frame, etc.), but even after removing them (Qt::FramelessWindowHint | Qt::CustomizeWindowHint) the result is far from acceptable. (Note: black area on the top and left is my physical screen frame.)

    What am I missing? Is there some argument to be set or added to the launch of QML app? Or is there something missing in the definition of the compositor?

    Code of my QML application:
    main.cpp:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
            &app, []() { QCoreApplication::exit(-1); },
            Qt::QueuedConnection);
        engine.loadFromModule("testqml", "Main");
    
        return app.exec();
    }
    

    Main.qml:

    import QtQuick
    import QtQuick.Window
    
    Window {
        width: 400
        height: 400
        visible: true
        title: qsTr("Hello QML World")
        
        Rectangle {
            visible: true
            id: rectangle
            color: "red"
            width: 400
            height: 400
    
            Text {
                id: text
                text: "This is QML code"
                font.pointSize: 14
                anchors.centerIn: parent
            }
        }
    }
    

    CMakeLists.txt:

    cmake_minimum_required(VERSION 3.16)
    
    project(testqml VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
    
    set(CMAKE_AUTORCC ON)
    
    qt_standard_project_setup(REQUIRES 6.5)
    
    qt_add_executable(apptestqml
        main.cpp
    )
    
    qt_add_qml_module(apptestqml
        URI testqml
        VERSION 1.0
        QML_FILES Main.qml
    )
    
    # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
    # If you are developing for iOS or macOS you should consider setting an
    # explicit, fixed bundle identifier manually though.
    set_target_properties(apptestqml PROPERTIES
    #    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.apptestqml
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    target_link_libraries(apptestqml
        PRIVATE Qt6::Quick
    )
    
    include(GNUInstallDirs)
    install(TARGETS apptestqml
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    
    
    1 Reply Last reply
    1
    • R Offline
      R Offline
      robgu
      wrote on last edited by
      #2

      Hello,

      I might have advanced a little bit with my problem.
      I changed my application to represent 2 vertical rectangles, one red, and the second divided into two squares (yellow and blue). I also fixed the window size to 256 by 256 pixels (I noticed regular glitches with only 2 rectangles so I thought it might be a buffering problem). My current application, when run in Weston, looks like expected (sorry for rasterization):
      3rects_weston.jpg

      However, in minimal-qml example compositor it is still not correct:
      3rects_minimal.jpg

      So it seems that the colors and the proportions are fine, but I have the impression that the buffer passed from my app to the compositor is read in an incorrect manner.

      What am I missing? Surface origin? Surface orientation? Other specific setting?
      Any help or suggestion will be appreciated...

      R 1 Reply Last reply
      1
      • R robgu

        Hello,

        I might have advanced a little bit with my problem.
        I changed my application to represent 2 vertical rectangles, one red, and the second divided into two squares (yellow and blue). I also fixed the window size to 256 by 256 pixels (I noticed regular glitches with only 2 rectangles so I thought it might be a buffering problem). My current application, when run in Weston, looks like expected (sorry for rasterization):
        3rects_weston.jpg

        However, in minimal-qml example compositor it is still not correct:
        3rects_minimal.jpg

        So it seems that the colors and the proportions are fine, but I have the impression that the buffer passed from my app to the compositor is read in an incorrect manner.

        What am I missing? Surface origin? Surface orientation? Other specific setting?
        Any help or suggestion will be appreciated...

        R Offline
        R Offline
        robgu
        wrote on last edited by
        #3

        I found the solution to my problem.

        I set environmental variable WAYLAND_DEBUG=1 and observed the output of my compositor and my app. Then I compared the same output with the logs of weston (launched with --log=file.log and -lproto). I noticed that the latter was using different buffers attached to the created surfaces.
        So I tested starting my application with QT_QUICK_BACKEND=software and it worked!
        However, there was no support for 3D (Quick3D examples).
        Checking further on the buffers I found that setting QT_WAYLAND_CLIENT_BUFFER_INTEGRATION=linux-dmabuf-unstable-v1 before starting the compositor is informing the clients to use that kind of buffers.
        This has entirely solved my problem on my configuration, I have now both QML applications and Quick3D applications rendered correctly, no need for additional settings on the clients' side.

        1 Reply Last reply
        2
        • R robgu has marked this topic as solved on
        • KH-219DesignK Offline
          KH-219DesignK Offline
          KH-219Design
          wrote on last edited by
          #4

          This has been a gripping mystery thread to (silently) follow. Thank you for continuing to update this thread! You had a silent "cheering squad" in the audience, despite me not having any help to provide :)

          www.219design.com
          Software | Electrical | Mechanical | Product Design

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved