View Full Version : QwtPlot - Changing Title fonts

25th April 2007, 17: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...


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


26th April 2007, 01: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.

26th April 2007, 08: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("...");


Eos Pengwern
30th November 2009, 15:30
Is there a way that I can control the title font size, though?

Qt allows the font to be set for a Widget, but greater levels of control require the use of style sheets. Qwt, by default, seems to use a very large version of the system font for the axis titles, and in my GUI (where there's limited space) that causes the plot itself to be made tiny.

Can I force Qwt to print titles in the same font size as the rest of the widget?

30th November 2009, 15:41
The size is an attribute of a QFont. How to assign a QFont is explained above.


Eos Pengwern
30th November 2009, 16:42
The size is an attribute of a QFont. How to assign a QFont is explained above.


:confused: But in that case, setting the plot font to the same font as the rest of the widget, for example by:

myPlot-> axisTitle(QwtPlot::xBottom).setFont(this -> font());

... should result in the font size, as well as the font style, being synchronised. My axes titles are still in a much bigger font than everything else, however.

What am I missing?

30th November 2009, 17:16
QwtPlot::axisTitle() is a getter and it doesn't make much sense to assign something to an object, that is returned by value.

Better do something like this:

QwtText title("BlaBla");
title.setFont(QFont("Helvetica", 20));
plot->setAxisTitle(QwtPlot::yLeft, title);


Eos Pengwern
30th November 2009, 19:59
Fantastic, that works! Thank you very much.

24th April 2012, 19:02
I've an additional question:
how it is possible to change a plot legend font size? and, if possible, the dash size indicating the curve color?

25th April 2012, 09:55
Isn't that a different question?

Ressurecting so old thread isn't the best idea.
Just create new thread so others can find it as well instead of using semi-related subject.

26th April 2012, 09:16
I've done it only beacause I've seen that somebody else did it before me (2007-2009)
thanks for the advice.