Hello,
Now i found a solution. You have to derive a new ComboBox from QComboBox. In this you must overload the paintEvent. This should look like this.
{
// draw the combobox frame, focusrect and selected etc.
initStyleOption(&opt);
painter.
drawComplexControl(QStyle::CC_ComboBox, opt
);
// draw something in the edit
QRect rect
= painter.
style()->subControlRect
(QStyle::CC_ComboBox,
&opt,
QStyle::SC_ComboBoxEditField,
this);
// now you have the rect of the lineEdit and a painter and you can paint wathever you want.
}
void MyComboBox::paintEvent(QPaintEvent * event)
{
QStylePainter painter(this);
// draw the combobox frame, focusrect and selected etc.
QStyleOptionComboBox opt;
initStyleOption(&opt);
painter.drawComplexControl(QStyle::CC_ComboBox, opt);
// draw something in the edit
QRect rect = painter.style()->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxEditField, this);
// now you have the rect of the lineEdit and a painter and you can paint wathever you want.
}
To copy to clipboard, switch view to plain text mode
Bookmarks