Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a scrollbar to a Qcombobox

I use python, and qt5, and qt designer. I want to add a scroll bar to the combo box. Any way to add a scrollbar using style-sheet? Other ways are also good.

This is the style-sheet currently used in the combo box.

QComboBox { 
    combobox-popup: 0;
}

I use this because I want to show the drop down list in 10 order. There seems to be no more data below because there are no scrollbars at this time.

If you know how, Please help me.

This is the situation now:

But I want:

like image 898
semikim Avatar asked Oct 29 '25 19:10

semikim


1 Answers

I solved it.

Add the following code.

#include <QAbstractItemView>
combobox.view().setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded).
like image 90
semikim Avatar answered Nov 01 '25 11:11

semikim