No text in compiled application



  • Hello oh you wise and experienced people,

    I'vo got a little problem. I already searched for a solution for hours. In case I overlooked something, I want to apology for bothering you in advance.

    After installting Qt 5.7.0 on my newest version of Ubuntu 16.04, I tried to make my first program, only to see that there is no text whatsoever. To make sure that it's not my codes fault, I checked one of the examples included in the installation. (dockwidgets in examples/widgets/mainwindows/dockwidgets)

    I add some pictures to show you what I mean. I can still highlight the text and when I copy it and paste it somewhere, it appears perfectly fine. Something must be missing, but I just can't find it.
    https://s29.postimg.org/5mecbcfrr/No_Text.jpg
    https://s30.postimg.org/chzs0hi0x/No_Text_Menu.jpg
    https://s29.postimg.org/rs69cj9wn/No_Text_Highlighted.jpg

    I found this nice, helpful page, but unfortunately, it did not solve my problem: http://amin-ahmadi.com/2016/09/23/qt-application-fonts-missing-or-invisible-in-linux-fixed/
    It sounds reasonable that there is some problem with some font, I just can't track down the error.

    Any other help would be highly appreciated


  • Moderators

    @JayD How did you install Qt 5.7? Do you see any warnings when you start a Qt app from console? Did you change the font in your Ubuntu installation?



  • @JayD I had this trouble when building on a build server and then trying to run on my machine. I ended up needing to add the fonts to my application.

    I copied the path/to/Qt/lib/fonts directory into my application so it looks like so:

    bin/
    fonts/
       allthefonts
    libs/
    myapp
    

    If you run your app on the command line it should tell you what is going on with not being able to find the fonts.

    Edit: oops forgot a super import part, in my execute script myapp, you need this:

    #!/bin/sh
    
    dir="$(dirname `readlink -f $0`)"
    LD_LIBRARY_PATH="$dir/libs:$LD_LIBRARY_PATH"
    QT_QPA_FONTDIR="$dir/fonts"
    export LD_LIBRARY_PATH QT_QPA_FONTDIR
    exec $dir/bin/myapp "$@"
    

    That QT_QPA_FONTDIR is what tells it where the fonts are.



  • Hi,

    first, sorry for my late response. That nasty thing called real life kicked in and kept me away from my dear computer.

    However, I was able to solve it, thanks to ambershark's suggestion. It turned out to be much easier, though. I simply had to add a folder called "fonts" in the lib direction - there was none before. You made me look in the right place, so thank you a lot!

    About jsulm's question (even when it's not important at this point, but you took the time to ask the question, so you deserve an answer), I installed it according to this helpful webpage http://doc.qt.io/qt-5/linux-building.html
    I don't see any warnings, at least no obvious one.

    However, my problem is solved. I wish you guys a wonderful Christmas or whatever you are going celebrate in December.



  • @JayD said in No text in compiled application:

    Hi,

    first, sorry for my late response. That nasty thing called real life kicked in and kept me away from my dear computer.

    However, I was able to solve it, thanks to ambershark's suggestion. It turned out to be much easier, though. I simply had to add a folder called "fonts" in the lib direction - there was none before. You made me look in the right place, so thank you a lot!

    About jsulm's question (even when it's not important at this point, but you took the time to ask the question, so you deserve an answer), I installed it according to this helpful webpage http://doc.qt.io/qt-5/linux-building.html
    I don't see any warnings, at least no obvious one.

    However, my problem is solved. I wish you guys a wonderful Christmas or whatever you are going celebrate in December.

    @JayD Excellent, glad it's all fixed. :) Have a great Christmas as well.

    Please make sure you mark the post as solved for other people in the future. :)

    Oh and yea you won't need the QPA_FONTDIR thing if you run all from the same directory. Since my application uses a start script to customize LD_LIBRARY_PATH I need to have that variable to tell it where the fonts are. If you ran from the top level directory just having the fonts dir would indeed work. Keep that in mind if you go to distribute the application as you'll probably need to use the style I use in my app (or something similar to control which libs you use on the target system).


Log in to reply
 

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