I have written an application using Qt and I am trying to deploy it. I built my application it and tried distributing it, but I ended up having to build Qt statically so that users don't need to install Qt's libraries just to run my application. The only problem is that the fonts are broken, and images don't load.
To statically build Qt, I did this:
./configure -static -release -ltcg -optimize-size -no-pch -prefix "/home/myuser/Qt/5.11.1-static" -skip webengine -nomake tools -nomake tests -nomake examples -fontconfig
make -j4
make -j4 install
There was then the issue of fonts not working. I kept getting the error "QFontDatabase: Cannot find font directory (Qt install directory)/libs/fonts", so I copied the dejavu fonts folder on my system to a folder called "fonts" in my program's directory and created a Bash script that set QT_QPA_FONTDIR to the new font directory. This made the error go away and made the text on my application visible, but when a password is being entered blank characters are displayed instead of asteriks or any other characters. Additionally, images do not show. I have a folder in the same directory as the application called "images" with my images inside, so I did this:
QIcon home("(program directory)/images/home.svg");
QIcon vpn("./images/vpn.svg");
ui->tabWidget->setTabIcon(0, home);
ui->tabWidget->setTabIcon(1, vpn);
The images do not show, but they do if the program is built using dynamic Qt. I tried both the full path and using ./ to refer to the current directory, but neither one results in the image appearing.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…