I want to draw a QComboBox inside a delegate that works great, except that I cannot figure out how to draw inline text visible inside the combo box.
The documentation states that QStyleOptionComboBox.currentText contains: "text for the current element of the combo box." but setting a variable has no effect.
This is my code:
void MyDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { QStyleOptionComboBox comboBoxOption; comboBoxOption.rect = option.rect; comboBoxOption.state = option.state; comboBoxOption.state |= QStyle::State_Enabled; comboBoxOption.editable = false; comboBoxOption.currentText = "CCC";
Looking at qwindowsxpstyle.cpp , I donโt see where the text of the โrealโ combined field is drawn, since currentText not used inside the drawComplexControl method. The only place it seems to be used for the Windows XP style is in qcommonstyle.cpp (line 2107, Qt 4.7.2), but I can't figure out how these two classes play together.
source share