[Interest] Qt and fixed width/pitch font

BRM bm_witness at yahoo.com
Mon Aug 13 22:38:37 CEST 2012


> From: Jan Kundrát <jkt at flaska.net>
> To: interest at qt-project.org
> Cc: 
> Sent: Monday, August 13, 2012 3:49 PM
> Subject: Re: [Interest] Qt and fixed width/pitch font
> 
> On 08/01/12 17:55, Carl Schumann wrote:
>>  So I tried QFont::setFixedPitch(true).
> 
> The following works for me:
> 
> // Ask for a fixed-width font. The problem is that these names wary 
> across platforms,
> // but the following works well -- at first, we come up with a made-up 
> name, and then
> // let the Qt font substitution algorithm do its magic.
> QFont font(QString::fromAscii("x-trojita-terminus-like-fixed-width"));
> font.setStyleHint(QFont::TypeWriter);
>

I ended up with the following after consulting this list quite a while ago:

QFont theFont(widget->font());
theFont.setFamily("Sans");
theFont.setFixedPitch(true);
widget->setFont(theFont);

$0.02

Ben




More information about the Interest mailing list