How to Disable and Enable selection for a item in QListWideget using Python

StackOverflow https://stackoverflow.com/questions/23124654

  •  05-07-2023
  •  | 
  •  

سؤال

hi guys im going a tools using a listwidget to list of objects to update some function. so the user select any no of item in list and perform a function.. once it done then that updated item should disable selection mode how to achieve this in PyQt

هل كانت مفيدة؟

المحلول

Query the selected items:

items = listWidget.selectedItems()

And set the flags for these selected items to Qt.NoItemFlags:

for item in items:
    item.setFlags(Qt.NoItemFlags)

This way you can disable the selection of the items.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top