Hello forum,
I am trying to render and see how different gradient types work and started with the linear gradient one.
The folloowing code snippet only shows a blank window widget that i have declared.
Code:
Any idea what i missed?
Regards
Sajjad
Printable View
Hello forum,
I am trying to render and see how different gradient types work and started with the linear gradient one.
The folloowing code snippet only shows a blank window widget that i have declared.
Code:
Any idea what i missed?
Regards
Sajjad
Hello,
It seems to me you created a painter that has nothing to do with the window, so it has no effect.
Anyway, what you should do if you want to handle painting of the widget yourself is subclass QWidget and reimplement its paintEvent, otherwise even if you managed to draw into the window, its own paintEvent would redraw it.
The "analog clock" example in Qt docs shows how to do it: http://doc.trolltech.com/4.2/widgets-analogclock.html
Hello,
Thanks again for the hint!!
Now i have another issue.
I would like to have multiple viewport on the same device (may that be QWidget, QPixmap, QPicture , QImage or QPrinter). I am not sure though if that will be efficient way to do that .
I attached an image where you will see three different shapes drawn with three
different types of gradient at three different placements. Now if i change the size of the window those shapes do not increase or decrease by size proportionally.
then i thought that having multiple viewport will be one of the solutions.
Can you suggest anything better?
Regards
Sajjad
To draw independently of the underlying device, you can simply do something like this:
Then you draw as if you had a window 100 x 100 pixels, and your drawing will be stretched to whatever size the window (or something else you're drawing to) actually has.
You can read more about this in the docs:
http://doc.trolltech.com/4.1/coordsy...ort-conversion
It also says how to maintain the aspect-ratio for your drawing to prevent deformation when you resize the window so it's not square.
Hi
I would suggest using QGraphicsScene, QGraphicsView, QGraphicsItem. These classes were made for mulitple viewports. Check the examples/graphicsview directory.