Reply
Thread Tools
Posts: 49 | Thanked: 41 times | Joined on Apr 2010
#1
Hi,
I'm trying to use checkable items in the listwidget. I can see the state changing allright in the code, but the graphics is not updated at all. What can I do to fix that? Anything missing in this code?

After putting all the items in the list, I set:

Code:
QObject.connect(self.listField, QtCore.SIGNAL('itemActivated(QListWidgetItem*)'), self.doItemChangeState)
the items have the following flags: QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled

then in doItemChangeState:

Code:
def doItemChangeState(self, item):
   """ invert the state of the activated item """

   if item.checkState() == QtCore.Qt.Checked:
      item.setCheckState(QtCore.Qt.Unchecked)
   else:
      item.setCheckState(QtCore.Qt.Checked)

Last edited by viraptor; 2010-04-05 at 19:27.
 
krk969's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#2
have you tried this on the QListWidget

setSelectionMode(QAbstractItemView::SingleSelectio n)

it should have worked even otherwise, are you using any custom styles ?
__________________
Developer of :
Buddy - budget/expense manager ( website )
Showtime - a telly channel listing viewer/reminder ( website )
Travelapp - london underground status/planner ( website )
Batlevel - desktop widget for battery level ( website )

“I hear and I forget. I see and I remember. I do and I understand.”
 
Posts: 49 | Thanked: 41 times | Joined on Apr 2010
#3
Unfortunately it didn't work. Not sure about the styles, because I'm hacking on someone else's application, but I tried forcing default stylesheet on all my elements and it still doesn't work - every list item has only a white dot on the left.
 
Reply


 
Forum Jump


All times are GMT. The time now is 13:19.