Solved StackView icon on Android
-
in my ToolBar I'm using ToolButtons with customized Images
Image { anchors.centerIn: parent source: "qrc:/your-path-to-images/menu.png" }
you can switch between menu.png and arrow_back.png depending on stackView.depth
Icons downloaded from https://material.io/resources/icons/ you'll find all needed sizes for ....png, ...@2x.png, ...@3x.png to always get the correct size depending from screen resolution -
Thanks guys. On the android device on which the bug is appear, no any font contains the required characters.
I'll have to use the icon, as I wrote @ekkescorner. The main reason why I don't want to do this is that the character approach has already been tested on different platforms and devices. But there seems to be no other way out.
-
@Bleach said in StackView icon on Android:
But there seems to be no other way out.
you can always ship a font with your application, one that has the characters, and load the font manually via
QFontDatabase::addApplicationFont QWidget
or FontLoader component in QML -
@J-Hilk Thanks. Which approach do you think would be better?
-
@Bleach They are equivalent, but since you're using QML, I would suggest the FontLoader
https://doc.qt.io/qt-5/qml-qtquick-fontloader.html#details
the docs show a website as source, you can just as well pass it an url that points to your resource system, and a ttf file in there
-
@Bleach said in StackView icon on Android:
Thanks. Which approach do you think would be better?
I prefer define myself the used fonts, so I am sure App looks same on every device.
I do something like this:int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); const QString fontFilename(QStringLiteral("Resources/fonts/GOTHIC.TTF")); QString fontFamily(QStringLiteral("Century Gothic")); if(QFileInfo::exists(fontFilename)) { int fontId = QFontDatabase::addApplicationFont(fontFilename); fontFamily = QFontDatabase::applicationFontFamilies(fontId).first(); QFontDatabase::addApplicationFont("Resources/fonts/GOTHICB.TTF"); QFontDatabase::addApplicationFont("Resources/fonts/GOTHICBI.TTF"); QFontDatabase::addApplicationFont("Resources/fonts/GOTHICI.TTF"); } // update default font QFont defaultFont = app.font(); defaultFont.setFamily(fontFamily); app.setFont(defaultFont); ... return app.exec(); }
-
@KroMignon Thanks again. Works great.
-
@Bleach your welcome
-
I hurried to the conclusion(
The font in the program changed, on the desktop and Android 5 everything works fine, but on the device with Android 8 the above-mentioned symbols are still not displayed correctly.
Desktop:
-
@Bleach said in StackView icon on Android:
I hurried to the conclusion(
The font in the program changes, on the desktop and Android 5 everything works fine, but on the device with Android 8 the above-mentioned symbols are still not displayed correctly.too bad :(
Do you have checkedQFontDatabase::addApplicationFont()
return value?
-1
is returned in case of error (cf. https://doc.qt.io/qt-5/qfontdatabase.html#addApplicationFont) -
@KroMignon said in StackView icon on Android:
Do you have checked QFontDatabase::addApplicationFont() return value?
Yes, it return positive value. And besides, the app font has changed to what I added.
UPD. Same issue on Android 10 (both case - default font and loaded by myself OpenSans).
-
@Bleach said in StackView icon on Android:
Yes, it return positive value. And besides, the app font has changed to what I added.
UPD. Same issue on Android 10 (both case - default font and loaded by myself OpenSans).Strange, I can not explain this behavior. Perhaps you should use pictures or try with fontawesome?
-
@Bleach FWIW, my Android phone (10) displays an appropriate icon for
\u2630
. -
@KroMignon said in StackView icon on Android:
Perhaps you should use pictures or try with fontawesome?
If it doesn't work with fonts, then I'll do it.
@LorenDB . Could you please send me your StackView sample apk? Ill try to deploy it on problem devices.
I reproduce this bug from Linux host. Prev tests was from Win 10.
Now this looks like a problem with the devices OS. But it is very strange that with two at once..