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. MacOS: QLineEdit height when changing font-size in stylesheet

MacOS: QLineEdit height when changing font-size in stylesheet

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 2 Posters 1.0k Views
  • 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.
  • R Offline
    R Offline
    rmweiss
    wrote on last edited by
    #1

    Hi,

    My Problem is that under MacOS/OSX with the default "macintosh" theme QLineEdits don't change their height when I set a larger font with "setStyleSheet".

    It works correctly when setting the fontsize with "setPointSize" or when I'm using another style like "fusion".

    Here's a sample script:

    import sys
    from PySide2.QtWidgets import *
    import PySide2
    
    class Form(QDialog):
        def __init__(self, parent=None):
            super(Form, self).__init__(parent)
    
            self.edit1 = QLineEdit(PySide2.__version__)
            self.edit2 = QLineEdit(PySide2.__version__)
            self.edit3 = QLineEdit(PySide2.__version__)
    
            layout = QVBoxLayout()
            layout.addWidget(self.edit1)
            layout.addWidget(self.edit2)
            layout.addWidget(self.edit3)
            self.setLayout(layout)
    
            f = self.edit1.font()
            f.setPointSize(27)
            self.edit1.setFont(f)
    
            self.edit2.setObjectName("edit2")
            self.setStyleSheet("QLineEdit#edit2 {font-size: 27pt}")
            self.edit3.setStyleSheet("font-size: 27pt")
    
    
    if __name__ == "__main__":
        app = QApplication(sys.argv)
        form = Form()
        form.show()
        sys.exit(app.exec_())
    

    Result without "-style" or with "-style macintosh":

    0_1568966254196_Bildschirmfoto 2019-09-20 um 09.49.07.png

    Result with "-style fusion":
    0_1568966299385_Bildschirmfoto 2019-09-20 um 09.50.08.png

    Is there anything missing/wrong in my script or is this a bug in QT?

    Thanks.

    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