Question about using dictionaries and QTableWidget

Sara Lochtie sara.lochtie at gmail.com
Wed Jun 19 12:00:03 EDT 2013


I have a table that gets new entries added to it in real time. Each entry has an ID and I am storing the ID in a dictionary. What I am trying to do is to have each ID in its own row and update within that row instead of adding a new one each time.

What I've done is store the ID in a dictionary and only added a new ID to the dictionary if it is not equal to any previous IDs.

I would like to assign the row number for each key in the dictionary to its value.

This is what I have:

	ID = int(epc[86:100],2)
		idEntry = self.idEntry
		
		if ID not in idEntry.keys():
			idEntry[ID] = self.nextRow
			self.nextRow += 1



lastRow = self.table.rowCount()
		self.table.setRowCount(self.nextRow)

		for entryPos in range(0, self.nextRow):
		    for fieldPos in range(6):
			entryPos = idEntry.get(ID)
			item = QtGui.QTableWidgetItem(str(data[entryPos][fieldPos]))	
			
			self.table.setItem(entryPos, fieldPos, item)
			 

			'''
			for k in idEntry.keys():
			    key = str(k)
			    value = idEntry.get(ID)
			    for v in idEntry.values():
			    	if data[value][1] == key:
				   self.table.setItem(value, fieldPos, item)
			'''	   



More information about the Python-list mailing list