Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Quoted
Originally posted by wkk1000
Thanks expert. I think i dont have the license policy for Qwt. Pls advise how to use the QPainter and Qcanvas for drawing the bar graph with axises and legends.
Thanks.
|
|
Source code |
1 2 3 4 5 6 |
void SimpleExampleWidget::paintEvent()
{
QPainter paint( this );
paint.setPen( Qt::blue );
paint.drawText( rect(), AlignCenter, "The Text" );
}
|
Quoted
Originally posted by AlexKiriukha
Quoted
Are you using Qt 3? The answer is a bit different with Qt 4.
Do you mean using Model/View Architecture?
Quoted
... y-axis needs to be scalable enough to stretch itself to correspond with the highest data values of a bar.. How shall i do that ?
quote]
Well, you can use logarithmic aproachs...
Lets say you would like y_axis to be 1, 2, 5, 10, 20, 50, 100 or other number kinda those...
First you should get number base 10 power,
p=(int)log10(your_max_y);
You can now now set
max_y_axis=pow(10,p);
But you must check the limits:
if (2*pow(10,p)>=your_max_y) max_y_axis=2*pow(2,p);
if (5*pow(10,p)>=your_max_y) max_y_axis=5*pow(5,p);
if (10*pow(10,p)>=your_max_y) max_y_axis=10*pow(10,p);
Now you got a "round" axis y max value close but greater then (or equal to) your max y value.
That's just a suggestion, of course!