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. StackView icon on Android
Forum Updated to NodeBB v4.3 + New Features

StackView icon on Android

Scheduled Pinned Locked Moved Solved QML and Qt Quick
18 Posts 5 Posters 2.2k Views 2 Watching
  • 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.
  • B Offline
    B Offline
    Bleach
    wrote on last edited by Bleach
    #3

    Thanks. But how to find out which font is "right"? That is, which will be correctly displayed on Linux, Win, Mac, Android ans iOS.

    KroMignonK 1 Reply Last reply
    0
    • B Bleach

      Thanks. But how to find out which font is "right"? That is, which will be correctly displayed on Linux, Win, Mac, Android ans iOS.

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #4

      @Bleach said in StackView icon on Android:

      That is, which will be correctly displayed on Linux, Win, Mac, Android ans iOS.

      For example "Segoe UI Symbol" contains those unicodes, but there are many others I think!
      Perhaps you should first check which fonts you are using on the system which it works ;)
      For example with:

      Text {
         text: "Used font is " + font.family + " - \u25C0 - \u2630"
      }
      

      You could also list available fonts with

      ListView {
          anchors.fill: parent; 
          model: Qt.fontFamilies()
      
          delegate: Item {
              height: 40; 
              width: ListView.view.width
              Text {
                  anchors.centerIn: parent
                  font.family: modelData
                  text: modelData + " - \u25C0 - \u2630"
              }
          }
      }
      

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      1 Reply Last reply
      1
      • ekkescornerE Offline
        ekkescornerE Offline
        ekkescorner
        Qt Champions 2016
        wrote on last edited by
        #5

        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

        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
        5.15 --> 6.9 https://t1p.de/ekkeChecklist
        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

        1 Reply Last reply
        1
        • B Offline
          B Offline
          Bleach
          wrote on last edited by Bleach
          #6

          Thanks guys. On the android device on which the bug is appear, no any font contains the required characters.
          alt text

          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.

          J.HilkJ 1 Reply Last reply
          0
          • B Bleach

            Thanks guys. On the android device on which the bug is appear, no any font contains the required characters.
            alt text

            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.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #7

            @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


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            B 1 Reply Last reply
            1
            • J.HilkJ J.Hilk

              @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

              B Offline
              B Offline
              Bleach
              wrote on last edited by Bleach
              #8

              @J-Hilk Thanks. Which approach do you think would be better?

              J.HilkJ KroMignonK 2 Replies Last reply
              0
              • B Bleach

                @J-Hilk Thanks. Which approach do you think would be better?

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by J.Hilk
                #9

                @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


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                2
                • B Bleach

                  @J-Hilk Thanks. Which approach do you think would be better?

                  KroMignonK Offline
                  KroMignonK Offline
                  KroMignon
                  wrote on last edited by
                  #10

                  @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();
                  }
                  

                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                  B 1 Reply Last reply
                  1
                  • KroMignonK KroMignon

                    @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();
                    }
                    
                    B Offline
                    B Offline
                    Bleach
                    wrote on last edited by
                    #11

                    @KroMignon Thanks again. Works great.

                    KroMignonK 1 Reply Last reply
                    0
                    • B Bleach

                      @KroMignon Thanks again. Works great.

                      KroMignonK Offline
                      KroMignonK Offline
                      KroMignon
                      wrote on last edited by
                      #12

                      @Bleach your welcome

                      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                      1 Reply Last reply
                      1
                      • B Offline
                        B Offline
                        Bleach
                        wrote on last edited by Bleach
                        #13

                        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.
                        alt text
                        Desktop:
                        alt text

                        KroMignonK LorenDBL 2 Replies Last reply
                        0
                        • B Bleach

                          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.
                          alt text
                          Desktop:
                          alt text

                          KroMignonK Offline
                          KroMignonK Offline
                          KroMignon
                          wrote on last edited by KroMignon
                          #14

                          @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 checked QFontDatabase::addApplicationFont() return value?
                          -1 is returned in case of error (cf. https://doc.qt.io/qt-5/qfontdatabase.html#addApplicationFont)

                          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                          B 1 Reply Last reply
                          1
                          • KroMignonK KroMignon

                            @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 checked QFontDatabase::addApplicationFont() return value?
                            -1 is returned in case of error (cf. https://doc.qt.io/qt-5/qfontdatabase.html#addApplicationFont)

                            B Offline
                            B Offline
                            Bleach
                            wrote on last edited by Bleach
                            #15

                            @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).

                            KroMignonK 1 Reply Last reply
                            0
                            • B Bleach

                              @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).

                              KroMignonK Offline
                              KroMignonK Offline
                              KroMignon
                              wrote on last edited by
                              #16

                              @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?

                              It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                              B 1 Reply Last reply
                              1
                              • B Bleach

                                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.
                                alt text
                                Desktop:
                                alt text

                                LorenDBL Offline
                                LorenDBL Offline
                                LorenDB
                                wrote on last edited by
                                #17

                                @Bleach FWIW, my Android phone (10) displays an appropriate icon for \u2630.

                                1 Reply Last reply
                                1
                                • KroMignonK KroMignon

                                  @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?

                                  B Offline
                                  B Offline
                                  Bleach
                                  wrote on last edited by Bleach
                                  #18

                                  @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..

                                  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