Search code examples
qtqcombobox

Position of dropdown in a QComboBox


Is there a way to know the position of the rectangle used by the drop-down of a QComboBox? (the rectangle where the down arrow is displayed)


Solution

  • I am not 100% sure if this is what you want, but a rectangle of Combobox arrow button can be obtained from the style:

    QStyle* style = comboBox->style(); 
    
    QStyleOptionComboBox option;
    option.rect = comboBox->rect();
    
    QRect r = style->subControlRect(QStyle::CC_ComboBox, &option, QStyle::SC_ComboBoxArrow);