PDA

View Full Version : Setting a font for a QInputDialog using option UseListViewForComboBoxItems.



cydside
13th October 2012, 12:55
Hi to all,
the following code will explain the problem better than words:



QFont font;
font.setPointSize(14);

QInputDialog tSelectFourMonthPeriod;
tSelectFourMonthPeriod.setFont(font);
tSelectFourMonthPeriod.setOption(QInputDialog::Use ListViewForComboBoxItems);
tSelectFourMonthPeriod.setWindowTitle(tr("Print Options."));
tSelectFourMonthPeriod.setLabelText(tr("Selection:"));
tSelectFourMonthPeriod.setComboBoxItems(prepareFou rMonthPerYearPeriod());
int ret = tSelectFourMonthPeriod.exec();

if (ret == QDialog::Accepted)
qDebug() << "Selection:" << tSelectFourMonthPeriod.textValue();


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.

ChrisW67
15th October 2012, 00:49
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:


QInputDialog tSelectFourMonthPeriod;
tSelectFourMonthPeriod.setStyleSheet("* { font-size: 14pt; }" );