UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Button QML Type: Text Coloring

    Scheduled Pinned Locked Moved App Development
    6 Posts 4 Posters 624 Views 2 Watching
    Loading More Posts
    • 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.
    • NotZaneyN Offline
      NotZaney
      last edited by

      So I want to preface this all with a little about myself. I am completely new to posting on forums so if this is done incorrectly I do apologize. I have been lurking and using this forum as a resource to dive into Ubuntu Touch. I have only recently decided that I am going to develop apps for this OS and am fully sold on using this.

      With all that being said I am working on my first app. It is a reading app based off creepypasta where you can find all kinds of stories focusing on creepy and horror. Currently working on basic UI and working with writers to get permission to add their stories.

      I have hit a weird hurdle though. I am trying to add some buttons and maybe this because I am new to QML and the proper way of implementing things. However, I can set the background color using the color option, text string, iconName, but there seems to be no way to change the color of the text and/or icon with a button. This seems like a really massive oversight.

      pparentP CiberSheepC 2 Replies Last reply Reply Quote 1
      • pparentP Offline
        pparent @NotZaney
        last edited by

        @NotZaney
        Did you try the solutions proposed in the answers of this post?

        https://stackoverflow.com/questions/40823503/qml-button-change-text-color

        NotZaneyN 1 Reply Last reply Reply Quote -1
        • NotZaneyN Offline
          NotZaney @pparent
          last edited by

          @pparent Thank you for getting back so fast. The only thing I found that would work was wrapping the text string like so: text: "<font color='#000000'>Author</font". However, while this solution allows me to color the text it does not color the icon. The same trick obviously doesn't work for the icon.

          I am just confused at why there is not already two options for text and icon color. I guess for now I am going to leave it alone. Although I would even be open to helping improve the API / adding these options at some point.

          I am sure I could get the buttons working and looking exactly how I want them, but I am just not trying to have 30 lines of nested code to build out a button lol.

          K 1 Reply Last reply Reply Quote 0
          • K Online
            kugiigi @NotZaney
            last edited by

            @NotZaney Are you using Lomiri toolkit? You might need to use Style. Check from docs if there's one for the button.

            In any case, you can actually make your own component in QML if you want to customize the contents of the button. Just put it in a separate QML file.

            1 Reply Last reply Reply Quote 0
            • CiberSheepC Offline
              CiberSheep @NotZaney
              last edited by

              @NotZaney the text color of the Button element will change automatically depending on the background color (that's true for the Lomiri Toolkit)

              https://ubports.gitlab.io/docs/api-docs/index.html?p=lomiriuserinterfacetoolkit%2Fqml-lomiri-components-button.html

              Another planet, another time, another universe!

              1 Reply Last reply Reply Quote 0
              • NotZaneyN Offline
                NotZaney
                last edited by

                Thank you guys! I got it figured out. I am new to this and did not dive deep enough into the documentation. I am now done with most, if not all, of the features for my app. I am now just filling it with content.

                This was helpful for anyone that may read this down the line and is having similar confusion:
                https://ubports.gitlab.io/docs/api-docs/index.html?p=lomiriuserinterfacetoolkit%2Flomiri-theming-styles.html

                Sorry for not getting back sooner. Been so caught up with life and working on the app I almost forgot about actually posting to the forums.

                Look forward to becoming more active around these parts! 🤠 Have a wonderful rest of your day!

                1 Reply Last reply Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post