Results 1 to 4 of 4

Thread: Change Font of QListWidget to Monospace Font

  1. #1
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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

  2. #2
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Change Font of QListWidget to Monospace Font

    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

  3. #3
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change Font of QListWidget to Monospace Font

    The following has no effect at all:
    Qt Code:
    1. QFont font;
    2. font.setStyleHint(QFont::Serif); //QFont::TypeWriter
    3. listWidget_MacroCommands->setFont(font);
    To copy to clipboard, switch view to plain text mode 
    The Font still is the default one.

    Matthias
    Last edited by jacek; 28th July 2008 at 15:52. Reason: changed [qtclass] to [code]

  4. #4
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Change Font of QListWidget to Monospace Font

    try this, i hope it works...

    Qt Code:
    1. QFont font;
    2. font.setStyleHint(QFont::Serif);
    3. font.setFamily( /*include your text here(as QString) */);
    4. listWidget_MacroCommands->setFont(font);
    To copy to clipboard, switch view to plain text mode 

    for more details see http://doc.trolltech.com/4.4/qfont.html#setFamily

Similar Threads

  1. How to prevent table header from font change.
    By kenny_isles in forum Qt Tools
    Replies: 1
    Last Post: 14th February 2007, 20:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.