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. Adapt text color depending on the background color
QtWS25 Last Chance

Adapt text color depending on the background color

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.5k Views
  • 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.
  • D Offline
    D Offline
    DavidM29
    wrote on 25 Jun 2018, 10:18 last edited by DavidM29
    #1

    Hello,

    I would like to know if there is any way to change a text color depending on the background color.
    I mean by that, if my background is black I want the text to be white if is white I want the text to be black.

    Here is an example where it invert the color. But just a switch to the most readable color would be enough. :

    0_1529921831095_32f6f31a-047e-4215-9401-66bad404296e-image.png

    Here a working example for HTML, CSS and JS example : https://codepen.io/jpod/pen/Aytcr

    R 1 Reply Last reply 25 Jun 2018, 11:38
    0
    • D DavidM29
      25 Jun 2018, 10:18

      Hello,

      I would like to know if there is any way to change a text color depending on the background color.
      I mean by that, if my background is black I want the text to be white if is white I want the text to be black.

      Here is an example where it invert the color. But just a switch to the most readable color would be enough. :

      0_1529921831095_32f6f31a-047e-4215-9401-66bad404296e-image.png

      Here a working example for HTML, CSS and JS example : https://codepen.io/jpod/pen/Aytcr

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 25 Jun 2018, 11:38 last edited by raven-worx
      #2

      @DavidM29
      see this approach.
      You will have to pass the background color yourself though.
      Also it won't be easily possible to have the text color changed in mid-text.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      D 1 Reply Last reply 25 Jun 2018, 11:45
      1
      • R raven-worx
        25 Jun 2018, 11:38

        @DavidM29
        see this approach.
        You will have to pass the background color yourself though.
        Also it won't be easily possible to have the text color changed in mid-text.

        D Offline
        D Offline
        DavidM29
        wrote on 25 Jun 2018, 11:45 last edited by
        #3

        @raven-worx

        Thank you for those elements ! It will help a bit event if I believe it will not be as I expected it to be.

        1 Reply Last reply
        0

        2/3

        25 Jun 2018, 11:38

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved