Reputation: 141
Is it possible to disable keyboard input for a QFontComboBox? The following code:
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class FontComboBox(QFontComboBox):
def __init__(self, parent=None):
super(FontComboBox, self).__init__(parent)
if __name__ == '__main__':
app = QApplication(sys.argv)
fonts = FontComboBox()
fonts.show()
sys.exit(app.exec_())
gives me (Mac OS X 10.8, PyQt4.8) a combobox which is editable and lets the user input basically anything. QtCreator, on the other hand, has this nice solution:
which looks more like an ordinary QComboBox. I've searched far and wide but can't seem to find settings for disabling keyboard input/changing the look of QFontComboBox. Any ideas?
Upvotes: 2
Views: 965
Reputation: 120608
A QFontComboBox is a QComboBox (i.e. a subclass of it), so all you need to do is:
fonts.setEditable(False)
Upvotes: 1