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
Eos Pengwern
30th November 2009, 14: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?
Uwe
30th November 2009, 14:41
The size is an attribute of a QFont. How to assign a QFont is explained above.
Uwe
Eos Pengwern
30th November 2009, 15:42
The size is an attribute of a QFont. How to assign a QFont is explained above.
Uwe
: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?
Uwe
30th November 2009, 16: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);
Uwe
Eos Pengwern
30th November 2009, 18:59
Fantastic, that works! Thank you very much.
Narciso
24th April 2012, 18: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?
thanks
Spitfire
25th April 2012, 08: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.
Narciso
26th April 2012, 08:16
Sorry,
I've done it only beacause I've seen that somebody else did it before me (2007-2009)
thanks for the advice.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.