PyQt QCombobox Setting Row Height Method

  • 2021-06-29 11:29:42
  • OfStack

Previously, I searched a lot of related information on the Internet, some said setting the height of icon to support item, some said adding view to fill in, but for an Qcombobox with only text, these are undoubtedly too cumbersome.It took a long time to discover a very simple method.

First add the following to the QSS stylesheet: (height is customized or width is set)

QComboBox QAbstractItemView::item { min-height: 30px; }

Then add the following code to the code:

self.ui_combobox.setView(QListView())

Okay, turn it on and look, wow, the height is really set!!!


Related articles: