In a QTableModel when I enter the following:
print model.supportedDropActions()
I just get:
<PyQt4.QtCore.DropActions object at 0x00000000081172E8>
How can I access an actual list of the supported drop actions from this object? At the documentation, it says, "The DropActions type is a typedef for QFlags. It stores an OR combination of DropAction values."
Note I am doing this in Python (PySide).
Related posts:
Background
First, make sure you understand how the bitwise-encoding works for these flags. There are really good descriptions in the accepted answers here:
Everyone that uses Qt and its relatives should read them, they will save a lot of headache if you ever want to extract information from the bitwise-encoded values.
Solution
While the following isn't for drop actions, but for item data roles, the principles are the exact same. As mentioned in the comments on the original post, you can recast the encoded value as an
int
and then decode it to a human-readable format using the enumeration (i.e., the translation between integer and role) provided by Qt online. I don't know why sometimes the docs represent the integers as hex versus decimals.In what follows, I represented the enumeration that I found online in a dictionary with the
int
as key, and the human-readable string description as value. Then use a function that casts the role as anint
to do the translation, using that dictionary.Then to use it, for instance in a model where roles are being thrown around and I want to see what's doing:
There are different ways to do it, but I find this very intuitive and easy to use.