python - How to get currently selected item from QListWidget and not what it remembers -
I'm not sure why you do not think that Everything selected: None selected: QListWidget
return on .selectedItems () is not there, even Only currently selected items (this previous item has been clicked or selected, so even if all of its items have been unselected, then it still remembers what it remembers). But I need to
QListWidget to return the code that is currently selected
.hasFocus () is not trusted because all the items are hidden Can be in QListWidget Focus. But it will still go ahead and return an item, while no one will be selected.
. Selected () does not work I just tried this with the code given below and it is working correctly
Import PySide Import from QtGui class MainWindow Sys (QtGui.QMainWindow) :. Def __init __ (self, parent = None): super () .__ init __ () self.resize (720, 480) central_widget = QtGui.QWidget (self) self.setCentralWidget (central_widget) layout = QtGui.QHBoxLayout ( Central_widget) self.text_edit = QtGui.QTextEdit (central_widget) layout.addWidget (self.text_edit) self.drop_list = QtGui.QListWidget (central_widget) self.drop_list.setSelectionMode (QtGui.QAbstractItemView.MultiSelection) self.drop_list.addItems ([' One ',' two ',' three ',' four ']) self drop_list.itemSelectionChanged.connect (self.show_List) layout.addWidget (self.drop_list) status = QtGui.QStatusBar (self) self.setStatusBar (status) action_ShowList = QtGui.QAction (self) action_ShowList.triggered.connect (self.show_List) self.show () def show_List (self): self.text_edit.setText (wrapper (self.drop_list.selectedItems ())) if __name__ == "__main__": app = QtGui.QApplication (s Ys.argv) frame = main Window () sys.exit (app.exec_ ())
Comments
Post a Comment