1 Attachment(s)
Font size for QwtPlot title?
Hi,
i'm testing this code with the "friedberg" example and latest Qwt version:
in plot.cpp after line 70 add a qDebug() line
Code:
setTitle( "Temperature of Friedberg/Germany" );
qDebug() << title().font(); // NEW
The output is:
QFont( "MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0" )
But the font size of the plot title is never 8.25.
Here
https://msdn.microsoft.com/de-de/lib...(v=vs.85).aspx
you can find, that "MS Shell Dlg 2 simply uses the Tahoma font regardless of language.".
I rebuild the title in Word Pad and the font size must be 14.
Attachment 11654
What's is going wrong here? Why is the size wrong of the returned font by title().font() ? Guess it is a bug.
Thx
Re: Font size for QwtPlot title?
What do you want?
for changing your title font, color, ..... you can use QwtText like this:
Code:
font14.setPointSize(14);
title.setText("Your Title");
title.setFont(font14);
Re: Font size for QwtPlot title?
Quote:
Originally Posted by
KT_HG
What do you want?
I wrote it: Why is the size wrong of the returned font by title().font() ?
Re: Font size for QwtPlot title?
Maybe because Qt uses the "closest matching installed font" only ( see the QFont docs ) ?
Uwe
Re: Font size for QwtPlot title?
Quote:
Originally Posted by
HappyCoder
I wrote it: Why is the size wrong of the returned font by title().font() ?
I had this same question, and could not make sense of Uwe's answer here. The cause is that there are two different QFonts that apply to the title - one from the QwtText returned from QwtPlot::title() and a different one from the QwtTextLabel returned from QwtPlot::titleLabel().
As HappyCoder demonstrated, plot->title().font() returns:
QFont( "MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0" )
Which you can verify is incorrect/not-in-use by assigning this back to the title by plot->title().setFont(), which results in the font visibly shrinking.
So, instead, plot->titleLabel()->font() gives you the actual initial/default font in the correct size, which returns:
QFont( "MS Shell Dlg 2,14,-1,5,75,0,0,0,0,0" )
For reference, I found this comment/thread that led me to this answer: https://www.qtcentre.org/threads/673...5432#post35432