i'm trying to generate a clickable HVS colorspace widget using QGraphicsView. The background of the whole QGraphicsView shall look like the image below (without jpeg-artefacts). Clicking at position x,y shall give the color under the cursor.
I don't want to use the image directly, instead i thought about to using qlineargradient in both directions (horizontal & vertical) using qstylesheets. In fact i can't figure out how to do it!
Simply using horizontal colorstops is straight foreward, i can't figure out how to add the additional vertical (white-color-black) gradient. What i got so far (inside constructor of inherited class from QGraphicsView) is:
QColor hsvColor[6];
hsvColor[0].setHsv(0, 255, 255);
hsvColor[1].setHsv(60, 255, 255);
hsvColor[2].setHsv(120, 255, 255);
hsvColor[3].setHsv(180, 255, 255);
hsvColor[4].setHsv(240, 255, 255);
hsvColor[5].setHsv(300, 255, 255);
QString styleH = QString("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,") +
QString("stop:0.000 rgba(%1, %2, %3, 255),").arg( hsvColor[0].red() ).arg( hsvColor[0].green() ).arg( hsvColor[0].blue() ) +
QString("stop:0.166 rgba(%1, %2, %3, 255),").arg( hsvColor[1].red() ).arg( hsvColor[1].green() ).arg( hsvColor[1].blue() ) +
QString("stop:0.333 rgba(%1, %2, %3, 255),").arg( hsvColor[2].red() ).arg( hsvColor[2].green() ).arg( hsvColor[2].blue() ) +
QString("stop:0.500 rgba(%1, %2, %3, 255),").arg( hsvColor[3].red() ).arg( hsvColor[3].green() ).arg( hsvColor[3].blue() ) +
QString("stop:0.666 rgba(%1, %2, %3, 255),").arg( hsvColor[4].red() ).arg( hsvColor[4].green() ).arg( hsvColor[4].blue() ) +
QString("stop:0.833 rgba(%1, %2, %3, 255),").arg( hsvColor[5].red() ).arg( hsvColor[5].green() ).arg( hsvColor[5].blue() ) +
QString("stop:1.000 rgba(%1, %2, %3, 255));").arg( hsvColor[0].red() ).arg( hsvColor[0].green() ).arg( hsvColor[0].blue() );
this->setStyleSheet(styleH);
This gives me:
I tried some while, now asking here:
Is it possible to draw a xy-gradient like above using qlineargradient & qstylesheets?
Maybe someone could give me a hint on how to do it using qstylesheets...
Thank u very much, in kind regard xam