QwtPlot - Changing Title fonts
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!
Re: QwtPlot - Changing Title fonts
Are these what you are looking for?
void QwtPlot::setTitleFont ( const QFont & f )
void QwtPlot::setAxisTitleFont ( int axis, const QFont & f )
Best.
Re: QwtPlot - Changing Title fonts
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.
Re: QwtPlot - Changing Title fonts
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
Re: QwtPlot - Changing Title fonts
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?
Re: QwtPlot - Changing Title fonts
The size is an attribute of a QFont. How to assign a QFont is explained above.
Uwe
Re: QwtPlot - Changing Title fonts
Quote:
Originally Posted by
Uwe
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:
Code:
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?
Re: QwtPlot - Changing Title fonts
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:
Code:
title.
setFont(QFont("Helvetica",
20));
plot
->setAxisTitle
(QwtPlot::yLeft, title
);
Uwe
Re: QwtPlot - Changing Title fonts
Fantastic, that works! Thank you very much.
Re: QwtPlot - Changing Title fonts
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
Re: QwtPlot - Changing Title fonts
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.
Re: QwtPlot - Changing Title fonts
Sorry,
I've done it only beacause I've seen that somebody else did it before me (2007-2009)
thanks for the advice.