[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Bug: QComboBox popup doesn't account for different font sizes
From:       Nathan Weston <nathan () genarts ! com>
Date:       2011-09-12 21:24:55
Message-ID: 4E6E78A7.3030605 () genarts ! com
[Download RAW message or body]

If I create a QComboBox, use a stylesheet to increase or decrease the 
font size, and put it within a QGridLayout, then the popup menu of the 
combo box draws incorrectly.

With smaller fonts, it's too small vertically, and even if there are 
only 2-3 items, the last item is cut off and a vertical scrollbar 
appears. With larger fonts, the popup is tall enough but the items 
overlap each other, leaving empty space at the bottom. Only 14px fonts 
seem to work correctly.

I'm using Qt 4.7.3 and PyQt 4.7.2. The problem occurs on Windows and 
Mac, but not Linux (though I may have different versions installed 
there, I didn't have a chance to check).

Attached is a small program which demonstrates the problem.

I imagine this is really a Qt bug, but I don't do Qt C++ development so 
I haven't had a chance to test it in that environment.


["combobox-bug.py" (text/plain)]

import sip
sip.setapi('QString', 2)        # Map QStrings to Python strings
sip.setapi('QVariant', 2)       # Auto-convert QVariants to/from Python types
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import droid

css = """
QComboBox {
  font: 10px;
}
"""

app = QApplication([])
w = QWidget()
g = QGridLayout(w)
c = QComboBox()
c.setStyleSheet(css)
for i in ['foo', 'bar', 'baz']:
    c.addItem(i)
g.addWidget(c)

w.show()
app.exec_()


_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic