PDA

View Full Version : Whats the right approach for drawing a simple graph?



Menia
2nd September 2010, 12:38
Hello,
a while ago I was asked to develop an app in QT and being new to it I've done some things poorly.
One of those things was to draw a graph..
At first I did this by just adding QFrames with backgrounds and used fixed calculated positions.

Now I wanted to do this with a layout, so that their positions would be calculated automatically and resize of widgets wouldnt be a problem.
I then added QHBoxLayout but then the 'poles' of the graph were centered vertically instead of the bottom..

After that I tried using QGraphicScene with the anchor property of QGraphicsView set to bottom but I'm still not getting results.

How should I go about drawing a simple graph?

Btw, some extra question of things I had in mind:
1. Are there spacers you can use with QGraphicScene?
2. Do you always need to hide and show a window in order to draw to it?

Would really appreciate some help, thanks!

wysota
2nd September 2010, 16:34
1. Are there spacers you can use with QGraphicScene?
How about using QGraphicsLinearLayout?

2. Do you always need to hide and show a window in order to draw to it?
No, you should never need to do that. If you do then you probably foget to notify Qt that the contents of the widget changed (by calling update()).