MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / sizeHint

Method sizeHint

src/ComboBoxDelegate.cpp:68–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66
67
68QSize ComboBoxDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
69{
70 Q_UNUSED(option)
71 Q_UNUSED(index)
72
73 QFontMetrics fm = qApp->fontMetrics();
74 QSize maxStringSize(0, 0);
75 int &width = maxStringSize.rwidth();
76 int &height = maxStringSize.rheight();
77
78 for(const ComboBoxItem &item : comboBoxItems) {
79 QRect rect = fm.boundingRect(item.first);
80
81 height = rect.height(); // Heights *should* all be the same
82 width = qMax(rect.width(), width);
83 }
84
85 QStyleOptionComboBox comobBoxStyleOptions;
86 return qApp->style()->sizeFromContents(QStyle::CT_ComboBox, &comobBoxStyleOptions, maxStringSize, nullptr);
87}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected