I'm attempting to draw a combobox in my QStyledItemDelegate-based delegate. I want the user to know that the item is a combobox but the view can contain thousands of items, so opening a persistent Editor for each item is not an option.
My paint function looks like this:

Qt Code:
  1. void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
  2. {
  3.  
  4. box.rect = option.rect;
  5. box.currentText = "test";
  6.  
  7. QApplication::style()->drawComplexControl(QStyle::CC_ComboBox, &box, painter, 0);
  8. QApplication::style()->drawControl(QStyle::CE_ComboBoxLabel, &box, painter, 0);
  9. }
To copy to clipboard, switch view to plain text mode 

Everything gets drawn correctly except the downward facing arrow on the combobox. It always gets drawn on the correct x coordinate but the y coordinate seems to be the one one would use to paint the control for the first item:
screenshot.png

The option.rect passed in contains the correct coordinates, and drawComplexControl is drawing outside of that rect.
So my question is where does Qt get the coordinates for the arrow from? How can it be outside of the style options rect?