[Qt-interest] Fixed width QLineEdit boxes.
Diego Iastrubni
diegoiast at gmail.com
Wed Feb 24 16:16:57 CET 2010
On Wed, Feb 24, 2010 at 2:52 PM, phil prentice <philp.cheer at talktalk.net>wrote:
> Thank you Diego for your help
>
> How exactly do I specify a fixed size font in QT? Do I have to do something
> like this?
>
> setFont(QFont("Monspace", 7));
>
> where Monospace I presume would have to be defined as a fixed size font??
>
> What makes the font a fixed width one?
>
I also check for platforms (sketch up code... not tested)
QFont f;
#ifdef __WIN32__
f.setFont(QFont("Courier New", 8));
#else
f.setFont(QFont("Monospace", 10));
#endif
QFontMetrics fm( f );
int pixelWidth = fm.width( "00" );
widget->setFixedWidth( pixelWidth + 10 ); // leave out some margins
Do you want to query the list of fonts, and see which one of them is fixed?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100224/912b3ec2/attachment.html
More information about the Qt-interest-old
mailing list