
Originally Posted by
bigjoeystud
I believe you have to override QwtScaleDraw with your own QwtScaleDraw::label routine. The label routine returns a QwtText which can have a color. Here's an example:
{
public:
ScaleDraw ();
virtual ~ScaleDraw () {};
virtual QwtText label
(double value
) const {
ret_val.setColor (_color);
return ret_val;
};
private:
};
class ScaleDraw: public QwtScaleDraw
{
public:
ScaleDraw ();
virtual ~ScaleDraw () {};
virtual QwtText label (double value) const
{
QwtText ret_val = QwtText (QString::number (value));
ret_val.setColor (_color);
return ret_val;
};
private:
QColor _color;
};
To copy to clipboard, switch view to plain text mode
Joey
Hi again, I think I triyed that solution before with no result.
Y create a similar code
{
public:
NewDraw
(QColor c
) {my_color
= c;
};
virtual QwtText label
(double value
) const {
ret_val.setColor (my_color);
return ret_val;
};
private:
};
class NewDraw: public QwtScaleDraw
{
public:
NewDraw(QColor c) {my_color = c;};
virtual QwtText label (double value) const
{
QwtText ret_val = QwtText (QString::number (value));
ret_val.setColor (my_color);
return ret_val;
};
private:
QColor my_color;
};
To copy to clipboard, switch view to plain text mode
And when I want to chande de color:
my_Plot
->setAxisScaleDraw
(QwtPlot::xBottom,
new NewDraw
(c
));
QColor c = QColorDialog::getColor( Qt::white, this );
my_Plot->setAxisScaleDraw(QwtPlot::xBottom, new NewDraw(c));
To copy to clipboard, switch view to plain text mode
But it doesnt work. Instead of changing the color of the numbers, all the numbers and ticks disappear. Any idea? Thanx
Bookmarks