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
    4 Posts 3 Posters 44 Views 1 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.
      • N 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 1 Reply 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

          N 1 Reply Last reply Reply Quote 0
          • N 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 Offline
              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
              • First post
                Last post