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.

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

Reply via email to