Change Font of QListWidget to Monospace Font
I use a QListWidget to display data in a column like way:
number: command: value
However, though all commands have the same length and the numbers always take the same space everything is no displayed in the right spacing. Therefore I need to change the font used to display the text inside the listwidget in a monospaced font.
So my question is: How do I change the font used inside the listwidget?
Matthias
Re: Change Font of QListWidget to Monospace Font
Quote:
So my question is: How do I change the font used inside the listwidget?
use the QWidget::setFont() function http://doc.trolltech.com/4.4/qwidget.html#font-prop
Re: Change Font of QListWidget to Monospace Font
The following has no effect at all:
Code:
font.
setStyleHint(QFont::Serif);
//QFont::TypeWriterlistWidget_MacroCommands->setFont(font);
The Font still is the default one.
Matthias
Re: Change Font of QListWidget to Monospace Font
try this, i hope it works...
Code:
font.
setStyleHint(QFont::Serif);
font.setFamily( /*include your text here(as QString) */);
listWidget_MacroCommands->setFont(font);
for more details see http://doc.trolltech.com/4.4/qfont.html#setFamily