QCombobox unkown top and botton scrollers
-
I've stylized a QComBox and it's QListView, and QScrollBar with css.
When the items reach a certain amount I want to set the QFrame of the Combobox's listview to a set height(i also am changing the menus lisview position for linux). This seems to be working as expected with subclassing the qcombobox below:class ComboBoxPop(QtWidgets.QComboBox): def showPopup(self): item_count = self.count() super().showPopup() container = self.view().parentWidget() if item_count > 15: self.view().setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) container.setFixedHeight(250) gp = self.mapToGlobal(self.rect().bottomLeft()) container.move(gp)
The issue is I'm getting these top and bottom scrollers. They dont seem to be apart of the QScrollBar... What is managing these and how can I either style them a different color or remove them.
Cheers
-
Hi and welcome to devnet,
Intriguing indeed !
Did you also play a bit with the example especially the drop-down part ?In any case, which version of PySide/PyQt are you using ?
@SGaist
Cheers,
So I made a simple test and it looks to be a Centos issue. In this example im using PySide2, 5.15.2.1 with windows 10 and Centos 7.
Is this something native to the Centos desktop? In any case the addition ofself.setStyleSheet('QComboBox {combobox-popup: 0;}')
in the example removes the two top and bottom arrows. Id just like to understand what exactly is going on here...
Here is the simple example if you have access to linux:
import sys from PySide2.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QComboBox from PySide2 import QtCore class ComboBoxPop(QComboBox): def showPopup(self): item_count = self.count() super().showPopup() container = self.view().parentWidget() if item_count > 20: self.view().setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) container.setFixedHeight(150) gp = self.mapToGlobal(self.rect().bottomLeft()) container.move(gp) class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setGeometry(100, 100, 400, 200) self.central_widget = QWidget() self.setCentralWidget(self.central_widget) self.layout = QVBoxLayout() self.central_widget.setLayout(self.layout) self.comboBox = ComboBoxPop() self.comboBox.addItems([f'item_{i}' for i in range(40)]) self.layout.addWidget(self.comboBox) # linux style to remove scrolling self.setStyleSheet('QComboBox {combobox-popup: 0;}') def main(): app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_()) if __name__ == "__main__": main()