How To Center Text In Qcombobox?
I've tried using QComboBox's model() with no apparent success. I wonder if it would be possible to align a text at the center of QCombobox. Aside from text alignment it seems the i
Solution 1:
You can use setAlignment
method:
from PyQt4 import QtGui, QtCore
class Window(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
layout = QtGui.QVBoxLayout(self)
self.combo = QtGui.QComboBox()
self.combo.setEditable(True)
self.combo.lineEdit().setAlignment(QtCore.Qt.AlignCenter)
self.combo.addItems('One Two Three Four Five'.split())
layout.addWidget(self.combo)
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
Post a Comment for "How To Center Text In Qcombobox?"