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

Adapt text color depending on the background color

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.5k Views 1 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.
  • D Offline
    D Offline
    DavidM29
    wrote on 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

    raven-worxR 1 Reply Last reply
    0
    • D DavidM29

      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

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on 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
      1
      • raven-worxR raven-worx

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

        • Login

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