That works great! =D Thanks!
However, I have some little problem.
I have a QStandardItem with a boolean value. (in column 4)
model = index.model()
vt = model.data(model.index(index.row(), 4, index.parent()), Qt.DisplayRole)
if vt.toBool() == False:
print "Nothing here"
else:
print "Hey! I found something!"
model = index.model()
vt = model.data(model.index(index.row(), 4, index.parent()), Qt.DisplayRole)
if vt.toBool() == False:
print "Nothing here"
else:
print "Hey! I found something!"
To copy to clipboard, switch view to plain text mode
I guess that .toBool tries to convert a QStandardItem to a boolean value instead of convert the value contained in the qstandarditem, and that's why it always return false when I'm sure that there are "true" items.
The .convert method from QVariant doesn't seem to be able to convert to qstandarditem, so, how could I do it? How could I convert the QVariant to QStandardItem?
Bookmarks