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. Strange QComboBox item height behaviour on MacOS
Forum Updated to NodeBB v4.3 + New Features

Strange QComboBox item height behaviour on MacOS

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 2 Posters 882 Views 3 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.
  • D Offline
    D Offline
    donquibeats
    wrote on last edited by
    #1

    I'm having problems with item heights in QComboBox widgets on MacOS. For the purpose of testing, I've got this little chunk of code:

            self.layout = QGridLayout(self)
            self.testComboBox = QComboBox()
            for n in range(1, 11):
                self.testComboBox.addItem("Item " + str(n))
            self.layout.addWidget(self.testComboBox, 0, 0)
    

    On Windows 10, all is fine, and it's looking like this:

    Windows QComboBox screengrab

    However the exact same code on a Mac is giving me this:

    MacOS QComboBox screengrab

    Please can someone explain why the first item is so much taller on MacOS and how I'm supposed to set the QComboBox so that the items are consistent heights cross-platform?

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

      Hi,

      What are you using ? PySide2 or PyQt5 ?
      What version ?
      How did you install it ?
      What version of macOS ?
      Can you profile a complete minimal sample that reproduces this ?

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

      1 Reply Last reply
      0
      • D Offline
        D Offline
        donquibeats
        wrote on last edited by
        #3

        Apologies for the lack of information in the original post. It's a PyQt5 project.

        In trying to create a standalone reproduction of the problem, I was able to narrow down where the problem lies. It appears to be an issue with the QDarkStyle stylesheet that I'm using. If I comment out the setStyleSheet line, then it works as expected on both platforms- but with the stylesheet applied, it looks fine on Windows but has the aforementioned variable-height issue on Mac.

        Here's a standalone bit of code:

        import sys
        from PyQt5.QtWidgets import QApplication, QGridLayout, QComboBox, QFrame, QDialog, QVBoxLayout
        import qdarkstyle
        
        
        class App(QDialog):
            def __init__(self):
                super().__init__()
                self.title = 'PyQt5 test window'
                self.layout = QVBoxLayout(self)
        
                self.testComboBox = QComboBox()
                for n in range(1, 11):
                    self.testComboBox.addItem("Item " + str(n))
        
                self.innerGrid = QGridLayout()
                self.innerGrid.addWidget(self.testComboBox, 0, 0)
                self.testComboBox_frame = QFrame()
                self.testComboBox_frame.setLayout(self.innerGrid)
        
                self.layout.addWidget(self.testComboBox_frame)
                self.initUI()
        
            def initUI(self):
                self.setWindowTitle(self.title)
                self.show()
        
        
        if __name__ == '__main__':
            app = QApplication(sys.argv)
            app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
            ex = App()
            sys.exit(app.exec_())
        
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you also provide that QDarkStyle ?

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

          1 Reply Last reply
          0
          • D Offline
            D Offline
            donquibeats
            wrote on last edited by
            #5

            QDarkStyle is available from PyPi here: https://pypi.org/project/QDarkStyle/

            In my project it is installed automatically as part of the requirements.txt file.

            If this isn't enough information, please let me know.

            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