def onActivated(self, idx): self.lbl.setText(self.distros[idx]) self.lbl.adjustSize() In the event handler, we set the selected text to the label and adjust the label's size to fit the text. Figure: QComboBox Q
combo.activated[str].connect(self.onActivated) self.setGeometry(300, 300, 300, 200) self.setWindowTitle('QtGui.QComboBox') self.show() def onActivated(self, text): self.lbl.setText(text) self.lbl.adjustSize() def main(): app = QtGui.QApplication(sys.argv) ex = Example() sys.exit...
def onActivated(self, text): self.lbl.setText(text) self.lbl.adjustSize() def main(): app = QApplication(sys.argv) ex = Example() sys.exit(app.exec()) if __name__ == '__main__': main() The example shows aQComboBoxand aQLabel. The combo box has a list of five options. ...
activated() When the user chooses an item 2 currentIndexChanged() Whenever the current index is changed either by the user or programmatically 3 highlighted() When an item in the list is highlightedAdvertisement - This is a modal window. No compatible source was found for this media.Example ...
activated() Used when an item is selected by the user. currentIndexChanged() Used when the item in the list has changed. ComboBox Usage The following sections provide examples that explain some different uses of the ComboBox using the QComboBox module of the PyQt library. Example 1: Create ...