PDA

View Full Version : QwtPlot - Changing Title fonts


MrGarbage
25th April 2007, 16:47
The answer to this may seem completely obvious - when I see it...

How does one change the Font used by QwtPlot to display the Graph and Axis titles?

It seems as if there should be a setAxisTitleFont() and setTitleFont()?

QwtPlot::initPlot() does:
d_data->lblTitle->setFont(QFont(fontInfo().family(), 14, QFont::Bold));

but I don't want to edit the source and rebuild the library...

Thanks!

conglu
25th April 2007, 19:18
Are these what you are looking for?
void QwtPlot::setTitleFont ( const QFont & f )
void QwtPlot::setAxisTitleFont ( int axis, const QFont & f )

Best.

MrGarbage
26th April 2007, 00:47
Those are exactly what I'm looking for.

Where are they?

I don't see them in the qwt doc or my qwt classes.

I have qwt-5.0.0rc1 - Windows platform.

Uwe
26th April 2007, 07:34
Title and axes are QWidgets. You can assign them a QFont simply by using QWidget::setFont: f.e plot->titleLabel()->setFont(...).

Also note, that Qwt uses QwtText objects for all of its label. A QwtText can have its own font, that is used instead of the widget font.
So another option is:

QwtText title("...");
title.setFont(...);
plot->setTitle(title);

HTH,
Uwe