Important: Please read the Qt Code of Conduct -

Problem with cross compiled code on raspberry pi

  • Hello, I am having problems with a Qt GUI application I created. Basically I created the application in my ubuntu to check if it compiles and works properly, however, if I set up the cross compiler (followed one of your tutorials and tried a hello world which works properly) and execute my code in the pi the UI does not display properly and basically I cant do anything:
    · Text disappears from buttons
    · Mouse disappears from screen (therefore cant click buttons)
    · Cant navigate buttons using tab key

    Any clues? maybe I cant use .ui files in the pi and have to use qml? Thank you in advance.

    2 Screenshots of what I get with the pi and what the program should actually look like:



  • Moderators

    Do you have fonts installed on the pi? Are the detected by Qt?

  • I ran on the pi terminal the following code to check the detected fonts: "fc-list – lists fonts"
    Changed the fonts of my program to DejaVu Sans (which was detected) and a few others, still nothing. Moreover there was a message in the terminal i hadn't noticed: "This plugin does not support propagateSizeHints()"

    I've been told that Qt5 has different rendering platforms, the standard for my compiled version is "eglfs", which is fullscreen EGL accelerated mobile application style. I need to run it another platform for example xcb or x11 with the command "./myprogram -platform xcb". Unfortunatelly i only have the following platform options and none of them work: eglfs,linuxfb,minimal,minimalegl,offscreen. I dont now how to install these, i'll google it see if i can find anything.

  • I tested something similar some time ago.
    Qt did find the fonts, but I had to tell my app explicitly the size of the fonts :

    @app.Setstylesheet("QWidget {font: bold 72px;}");@

    Hope this helps you.

  • I also ran into this and defining the size using pixelSize solved it, once I changed all my text rendering elements so that they would use pixelSize I was set to go.

    However later on, I found that I was not being able to load fonts other than the default one and after I also ran into trouble when I started using TextInput elements with echoMode set to password as the stars (*) just wouldn't show.

    Trying to solve my font loading problems I came up with the following solution.

    I included the ttf files as a resource and then used a FontLoader, I'm not sure whether this works using absolute/relative paths directly instead of the qrc path, But since I found it to work with qrc I just kept it this way.

    @FontLoader {
    id: freeSansLoader
    source: "qrc:///fonts/resources/fonts/FreeSans.ttf"
    onStatusChanged: if (loader.status == FontLoader.Ready) console.log('Loaded')

    After having declared the loader I can just directly write: "FreeSans"@

    On text rendering elements (Text, TextEdit, TextInput).

    A nice additional surprise after I worked around the font loading problem, was that those inputs with echoMode set to password now seemed to display the stars (*), pwetty cool.. one less bug to deal with....



Log in to reply