Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGradient::color(pos);?
Forum Updated to NodeBB v4.3 + New Features

QGradient::color(pos);?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 630 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    I want to use a Q(Linear)Gradient in a way that is similar to a colour chooser. But given a position there doesn't appear to be a way to extract the colour at that position which seems rather a shame.

    Is there any easy way to achieve this? If necessary I can try to locate the source repository and "borrow" the relevant code... Are there any protected methods I could use to achieve this that aren't in the documentation?

    This is a bit more complex than just finding the colour at one of the defined stops which is trivial. The control I'm working on would also allow you to double click between stops to add an extra stop, hence the wish to find the colour at a specific position.

    David

    jsulmJ 1 Reply Last reply
    0
    • PerdrixP Perdrix

      I want to use a Q(Linear)Gradient in a way that is similar to a colour chooser. But given a position there doesn't appear to be a way to extract the colour at that position which seems rather a shame.

      Is there any easy way to achieve this? If necessary I can try to locate the source repository and "borrow" the relevant code... Are there any protected methods I could use to achieve this that aren't in the documentation?

      This is a bit more complex than just finding the colour at one of the defined stops which is trivial. The control I'm working on would also allow you to double click between stops to add an extra stop, hence the wish to find the colour at a specific position.

      David

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Perdrix Not the most efficient way: https://www.qtcentre.org/threads/49693-How-to-get-color-of-pixel-or-point

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by
        #3

        I was thinking in terms of the QGradient position value (i.e. 0.0 to 1.0) rather than using some form of pixel under mouse technique as the rodent won't necessarily be in the gradient but may well be next to it where the markers are held (not 100% trivial to convert to a position where it would be over the gradient itself):

        0c70aa8a-1d7e-4e33-a101-dca4948df042-image.png

        Thanks
        David

        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