Results 1 to 2 of 2

Thread: Setting a font for a QInputDialog using option UseListViewForComboBoxItems.

  1. #1
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Setting a font for a QInputDialog using option UseListViewForComboBoxItems.

    Hi to all,
    the following code will explain the problem better than words:

    Qt Code:
    1. QFont font;
    2. font.setPointSize(14);
    3.  
    4. QInputDialog tSelectFourMonthPeriod;
    5. tSelectFourMonthPeriod.setFont(font);
    6. tSelectFourMonthPeriod.setOption(QInputDialog::UseListViewForComboBoxItems);
    7. tSelectFourMonthPeriod.setWindowTitle(tr("Print Options."));
    8. tSelectFourMonthPeriod.setLabelText(tr("Selection:"));
    9. tSelectFourMonthPeriod.setComboBoxItems(prepareFourMonthPerYearPeriod());
    10. int ret = tSelectFourMonthPeriod.exec();
    11.  
    12. if (ret == QDialog::Accepted)
    13. qDebug() << "Selection:" << tSelectFourMonthPeriod.textValue();
    To copy to clipboard, switch view to plain text mode 

    and it runs nice but the QListView's font is NOT what I set, it's the default!!!
    How can I set the same for the QListView?
    Thanks in advance.

    P.S.: It happens on Windows 7, Qt 4.8.3 Qt Creator 2.5.2.
    Last edited by cydside; 13th October 2012 at 13:19.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Setting a font for a QInputDialog using option UseListViewForComboBoxItems.

    It behaves as expected here on Linux but I see different behaviour on Windows XP: only the dialog labels and buttons change. Might be worth search for a bug report.

    You seem to be able to work around it using a style sheet to set the font:
    Qt Code:
    1. QInputDialog tSelectFourMonthPeriod;
    2. tSelectFourMonthPeriod.setStyleSheet("* { font-size: 14pt; }" );
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Building from source option setting
    By sajis997 in forum Installation and Deployment
    Replies: 0
    Last Post: 21st March 2012, 15:55
  2. Replies: 2
    Last Post: 19th November 2011, 16:50
  3. How to using/setting the font caching
    By iceman in forum Newbie
    Replies: 5
    Last Post: 28th July 2010, 05:35
  4. Replies: 1
    Last Post: 11th March 2010, 21:30
  5. QCompleter once again (setting a font)
    By Lykurg in forum Qt Programming
    Replies: 2
    Last Post: 15th March 2007, 12:42

Tags for this Thread

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.