Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QCombobox unkown top and botton scrollers
Forum Updated to NodeBB v4.3 + New Features

QCombobox unkown top and botton scrollers

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 402 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • guimunkeyG Offline
    guimunkeyG Offline
    guimunkey
    wrote on last edited by
    #1

    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

    combo_box.jpg

    1 Reply Last reply
    0
    • guimunkeyG Offline
      guimunkeyG Offline
      guimunkey
      wrote on last edited by
      #2

      Hmmm i seem to get rid of them with a css syle, I pulled from a stackover flow example:

      QComboBox {
          combobox-popup: 0;
      }
      

      Combobox still works as expected...what going on here? I can't find add documentation of combobox-popup

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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 ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        guimunkeyG 1 Reply Last reply
        0
        • SGaistS SGaist

          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 ?

          guimunkeyG Offline
          guimunkeyG Offline
          guimunkey
          wrote on last edited by guimunkey
          #4

          @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.
          qt_win_centos.jpg
          Is this something native to the Centos desktop? In any case the addition of

          self.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()
          
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved