1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| import sys
from PyQt5 import (QtWidgets, QtCore)
#############################################################################
class Fenetre(QtWidgets.QMainWindow):
#========================================================================
def __init__(self, parent=None):
super().__init__(parent)
self.resize(300,200)
self.statusbar = QtWidgets.QStatusBar(self)
self.setStatusBar(self.statusbar)
self.combo = QtWidgets.QComboBox(self)
self.combo.setMouseTracking(True)
self.combo.setStatusTip("test")
self.combo.addItem("aaa")
self.combo.setItemData(0, "111222333", QtCore.Qt.StatusTipRole)
self.combo.addItem("bbb")
self.combo.setItemData(1, "444555666", QtCore.Qt.StatusTipRole)
self.combo.addItem("ccc")
self.combo.setItemData(2, "777888999", QtCore.Qt.StatusTipRole)
posit = QtWidgets.QGridLayout()
posit.addWidget(self.combo, 0, 0)
self.setLayout(posit)
#############################################################################
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
fenetre = Fenetre()
fenetre.show()
sys.exit(app.exec_()) |
Partager