PDA

View Full Version : A Widget like this



prashant
5th November 2009, 19:09
Related To: PYQt 4.6.1

I have to create a widget as shown in the image. You can call this widget as a ramp/gradient maker. I am planning ti implement this using graphicsview/graphicsitem. Please point me out the right direction to implement this widget.

Functionality:
1. Clicking on the gradient open color dialog with color that has been clicked, and a new color is inserted a give horizontal/vertical point.

2. you can move particular color by using small circle pointers and you can delete an entry by using small cross box.

3. Increasing the size of dialog, by stretching it or maximizing it, increases the size of ramp widget also.

4. There is an option of drawing the ramp vertical or horizontal. (second image)

Drawing/painting a gradient is not a problem, but implementing the functionality of circle pointers is concerned.

wysota
5th November 2009, 22:19
I think QGraphicsView is an overkill here. A simple QWidget subclass would be sufficient.

prashant
6th November 2009, 05:24
I was also think the same for QGraphicsView.
Could you please give me some hints to start, specially moving those circle pointers to move the color.

aamer4yu
6th November 2009, 05:52
Well, have you looked at Qt Demos-->Demonstrations-->Gradients ??
May be the source code for that is available with Qt... and its quite similar to what you want..

Anyways,, I would suggest explore all examples in Qt Demos... a must for beginers... it gives u brief idea of what Qt is capable of ... and acts like a index to problem solutions :)

prashant
6th November 2009, 10:13
I have seen all the gradients related demo in example. As "wysota" pointed out that QGraphicsView would be an overkill, I would like to know other options to achieve the task.

Painting a gradient is not a problem, main concern are circle point interactions and drawing the ramp horizontally or vertically.

wysota
6th November 2009, 12:34
Could you please give me some hints to start, specially moving those circle pointers to move the color.

Override mousePressEvent, mouseMoveEvent and mouseReleaseEvent for your widget. Have a variable somewhere keeping the position of your circles and when mouse events occur change positions of your circles and update the widget. In paintEvent render both the gradient and the circles.