Hi,
I'm triying to change the color of the numbers and axis of a Qwt plot. I think there is no simple way to do it (like myplot->setAxisColor(Axis id, QColor c).
So I tried to create a subclass of a QwtScaleDraw, and set the color to it. Then, set this ScaleDraw to my plot.
Here is de code:
Here is my subclass header file
{
public:
};
class myAxisDraw: public QwtScaleDraw
{
public:
myAxisDraw(QColor c);
};
To copy to clipboard, switch view to plain text mode
Here the cpp file
myAxisDraw
::myAxisDraw(QColor c
){
painter->setPen(c);
draw(painter, palette);
}
myAxisDraw::myAxisDraw(QColor c)
{
QPalette palette(c);
QPainter * painter = new QPainter;
painter->setPen(c);
draw(painter, palette);
}
To copy to clipboard, switch view to plain text mode
And here is the function to change de color
void myClass::myFunction()
{
myAxisDraw * a = new myAxisDraw(c);
myPlot->setAxisScaleDraw(myPlot->xBottom, a );
myPlot->replot();
}
void myClass::myFunction()
{
QColor c = QColorDialog::getColor( Qt::white, this );
myAxisDraw * a = new myAxisDraw(c);
myPlot->setAxisScaleDraw(myPlot->xBottom, a );
myPlot->replot();
}
To copy to clipboard, switch view to plain text mode
It compiles but nothing happends. Any idea?
Thanks in advance!!
Bookmarks