您可以使用标志的常用位掩码设置dropActions
。从the docs,我们有以下可能的删除操作:
Action Value Result
Qt::CopyAction 0x1 (1) Copy the data to the target.
Qt::MoveAction 0x2 (2) Move the data from the source to the target.
Qt::LinkAction 0x4 (4) Create a link from the source to the target.
Qt::ActionMask 0xff (255) [none given in docs]
Qt::IgnoreAction 0x0 (0) Ignore the action (do nothing with the data).
我被ActionMask
操作弄糊涂了。我没有找到任何关于它的讨论(例如,here或here),甚至没有任何使用它的例子(比如在Nullege)。它的值是11111111,因此,任何时候,如果你按位or
它与任何其他dropaction一起,你将再次以ActionMask
结束。在
那么,ActionMask
是为了什么?什么时候用的?文件记录在哪里?在
编辑:
正如在接受的答案中指出的,我在枚举中遗漏了一个DropAction,这可能是关键:
^{pr2}$
通常,掩码是一个值,用于使用按位运算包括或排除另一个值的某些位。在
DropAction enum的定义包含另一个标志:
在面罩的范围之外。因此,可以使用掩码来筛选这些值,如下所示:
^{pr2}$反之亦然:
至于为什么使用它:Qt4在其源代码中精确地使用它,即gui/kernel/qmotifdnd_x11.cpp中的
QtDropActionToDndOperation
函数。你会怎么做。。。在相关问题 更多 >
编程相关推荐