I'm handling tool tips for some items in my model, but the ones with tool tips are hidden/absent in my combo box drop-down. Here is the data function of the model I'm using in my combo box:
QVariant MyModel::data(const QModelIndex& index, const int role) const
{
const DataStruct& data = m_data[index.row()];
switch (role)
{
case Qt::DisplayRole:
return data.name;
case Qt::EditRole:
case Qt::UserRole:
return QVariant::fromValue(data.value);
case Qt::ToolTip:
if (data.condition)
{
return tr("Tool tip text");
}
return {};
default:
return {};
}
}
case Qt::ToolTip:should becase Qt::ToolTipRole:.Qt::ToolTipmatchesQt::SizeHintRole- and when QVariant("any test") is interpreted as aQSizeit is-1, -1causing the combo box to not show it.