From 7a1ef1499cad0ac3b5a3059aef2a85003c7ba544 Mon Sep 17 00:00:00 2001 From: maicss Date: Sat, 8 Oct 2016 18:17:53 -0500 Subject: [PATCH] =?UTF-8?q?Update=20=E6=8B=96=E6=8B=BD.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 拖拽.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/拖拽.md b/拖拽.md index 2af0c08..8dc7f84 100644 --- a/拖拽.md +++ b/拖拽.md @@ -243,14 +243,14 @@ def mousePressEvent(self, e): if e.button() == Qt.LeftButton: print('press') ``` -We print 'press' to the console if we left click on the button with the mouse. Notice that we call mousePressEvent() method on the parent as well. Otherwise, we would not see the button being pushed. +左键点击按钮,会在控制台输出“press”。注意,我们在父级上也调用了`mousePressEvent()`方法,不然的话,我们是看不到按钮按下的效果的。 ``` position = e.pos() self.button.move(position) ``` -In the dropEvent() method we code what happens after we release the mouse button and finish the drop operation. We find out the current mouse pointer position and move the button accordingly. +在`dropEvent()`方法里,我们定义了按钮按下后和释放后的行为,获得鼠标移动的位置,然后把按钮放到这个地方。 ``` e.setDropAction(Qt.MoveAction) e.accept() ``` -We specify the type of the drop action. In our case it is a move action. \ No newline at end of file +指定放下的动作类型为moveAction。 \ No newline at end of file