Qt-DropActions:ActionMask的作用是什么?

2024-05-20 23:49:45 发布

您现在位置:Python中文网/ 问答频道 /正文

您可以使用标志的常用位掩码设置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操作弄糊涂了。我没有找到任何关于它的讨论(例如,herehere),甚至没有任何使用它的例子(比如在Nullege)。它的值是11111111,因此,任何时候,如果你按位or它与任何其他dropaction一起,你将再次以ActionMask结束。在

那么,ActionMask是为了什么?什么时候用的?文件记录在哪里?在

编辑:

正如在接受的答案中指出的,我在枚举中遗漏了一个DropAction,这可能是关键:

^{pr2}$

Tags: thetofromdocssourcetargetdatahere
1条回答
网友
1楼 · 发布于 2024-05-20 23:49:45

通常,掩码是一个值,用于使用按位运算包括或排除另一个值的某些位。在

DropAction enum的定义包含另一个标志:

    Qt::TargetMoveAction    0x8002

在面罩的范围之外。因此,可以使用掩码来筛选这些值,如下所示:

^{pr2}$

反之亦然:

>>> int(a & ~Qt.ActionMask)
32768

至于为什么使用它:Qt4在其源代码中精确地使用它,即gui/kernel/qmotifdnd_x11.cpp中的QtDropActionToDndOperation函数。你会怎么做。。。在

相关问题 更多 >