Hi,
I want to overwrite an axis label (with a QLineEdit in z direction, not C++) in order to give the user a possibility to change axis boundaries directly on a label. I found that the axis labels don't use the applications font - please consider this program:
#include <QApplication>
#include <QMainWindow>
#include "qwt_plot.h"
#include <QDebug>
#include "qwt_scale_draw.h"
#include "qwt_text.h"
{
public:
}
return _plot;
}
private:
};
int main(int argc, char *argv[])
{
Demo w;
w.
setFont(QFont("Arial"));
w.show();
qDebug() << "Plot" << w.plot()->font();
qDebug
() <<
"ScaleDraw label" << w.
plot()->axisScaleDraw
(QwtPlot::xBottom)->label
(450).
font();
return a.exec();
}
#include <QApplication>
#include <QMainWindow>
#include "qwt_plot.h"
#include <QDebug>
#include "qwt_scale_draw.h"
#include "qwt_text.h"
class Demo : public QMainWindow
{
public:
Demo(QWidget *parent = 0) : QMainWindow(parent){
_plot = new QwtPlot(this);
}
QwtPlot *plot() {
return _plot;
}
private:
QwtPlot *_plot;
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Demo w;
w.setFont(QFont("Arial"));
w.show();
qDebug() << "Plot" << w.plot()->font();
qDebug() << "ScaleDraw label" << w.plot()->axisScaleDraw(QwtPlot::xBottom)->label(450).font();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
This program gives the output:
Plot QFont( "Arial,8.14286,-1,5,50,0,0,0,0,0" )
ScaleDraw label QFont( "MS Shell Dlg 2,8.14286,-1,5,50,0,0,0,0,0" )
So obviously the applications font isn't propagated to QwtScaleDraw. QwtScaleDraw is not a QWidget, so this must be done by hand actually. (feature request if it is not implemented in the mean time - I'm using qwt6.1.2)
But back to the labels: if I use the font MS Shell Dlg on my QLineEdit, the text looks different from the other labels. I'm confused now: on the one hand the label says, MS Shell Dlg is used for rendering the text, on the other hand it doesn't look like MS Shell Dlg.
How can I get the font used to render the labels?
Best regards,
Carsten
Bookmarks