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. How to get color value at Click position?
Qt 6.11 is out! See what's new in the release blog

How to get color value at Click position?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 725 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.
  • T Offline
    T Offline
    tanthinh1510
    wrote on last edited by
    #1

    Hi everyone!
    I have Rectangle with gradient and ColorAnimation
    I want to send signal on click with selected color. But I can’t know color of pixel at given position.
    Have you ideas to do this ?
    Thanks!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tanthinh1510
      wrote on last edited by
      #2

      My code Rectangle
      @import QtQuick 2.0

      Rectangle{
      id:rect
      width:300
      height:300
      rotation:-90
      property color colorValue: rect.color
      gradient: Gradient {
      GradientStop {
      position: 0.0
      SequentialAnimation on color {
      loops: Animation.Infinite
      ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
      ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
      ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
      ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
      ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
      ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
      ColorAnimation { from: "black"; to: "green"; duration: 2000 }
      }
      }
      GradientStop {
      position: 0.16
      SequentialAnimation on color {
      loops: Animation.Infinite
      ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
      ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
      ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
      ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
      ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
      ColorAnimation { from: "black"; to: "green"; duration: 2000 }
      ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
      }
      }
      GradientStop {
      position: 0.33
      SequentialAnimation on color {
      loops: Animation.Infinite
      ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
      ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
      ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
      ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
      ColorAnimation { from: "black"; to: "green"; duration: 2000 }
      ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
      ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
      }
      }
      GradientStop {
      position: 0.5
      SequentialAnimation on color {
      loops: Animation.Infinite
      ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
      ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
      ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
      ColorAnimation { from: "black"; to: "green"; duration: 2000 }
      ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
      ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
      ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
      }
      }
      GradientStop {
      position: 0.76
      SequentialAnimation on color {
      loops: Animation.Infinite
      ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
      ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
      ColorAnimation { from: "black"; to: "green"; duration: 2000 }
      ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
      ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
      ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
      ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
      }
      }
      GradientStop {
      position: 0.85
      SequentialAnimation on color {
      loops: Animation.Infinite
      ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
      ColorAnimation { from: "black"; to: "green"; duration: 2000 }
      ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
      ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
      ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
      ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
      ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
      }
      }
      GradientStop {
      position: 1.0
      SequentialAnimation on color {
      loops: Animation.Infinite
      ColorAnimation { from: "black"; to: "green"; duration: 2000 }
      ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
      ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
      ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
      ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
      ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
      ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
      ColorAnimation { from: "black"; to: "green"; duration: 2000 }
      }
      }
      }

      }
      

      @

      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