简体   繁体   English

pydev代码完成和在pyqt和qt4中输入鸭子

[英]pydev code completition and duck typing in pyqt and qt4

Hello i have just installed pydev because of code completition. 您好,由于代码完成,我刚刚安装了pydev。 my first sketch is some simple qt widget. 我的第一个草图是一些简单的qt小部件。

i'm ovverriding mouseMoveEvent: 我在ovoverriding mouseMoveEvent:

def mouseMoveEvent(self, event):

    mouse = event.pos()

now.. i know that event variable is a QtCore.QPoint type.. but code completition does not work.. ok i understand it: there is no hard typing, there is duck typing, in theory event could be of any possible type.. 现在..我知道事件变量是QtCore.QPoint类型..但是代码补全无法工作..好的,我明白了:没有硬类型,没有鸭子类型,理论上事件可以是任何可能的类型。 。

instead if i have this code: 相反,如果我有此代码:

point = QtCore.QPoint()

when i write point. 当我写点。 code completition works fine (of course it knows the type without doubt!) 代码补全工作正常(当然,毫无疑问它知道类型!)

i want code completition also in overriding mouseMoveEvent.. what else can i do besides change language and shift in c++ or java? 我还希望在覆盖mouseMoveEvent中实现代码完成。除了更改语言并在C ++或Java中进行转换外,我还能做什么?

SOLUTION : as gary pointed me in this thread this trick works: 解决方案 :正如gary此线程中指出的那样,此技巧有效:

def mouseMoveEvent(self, event):
    assert(isinstance(event, QtGui.QMouseEvent))

    mouse = event.

I'm certain that this is not a problem Python, but rather with how your PyDev is set up. 我敢肯定这不是Python的问题,而是PyDev的设置方式。

There are plenty of Python IDE's available that have no problem handling the sort of code-completion you mention - such as eric , for instance. 有许多可用的Python IDE可以毫无问题地处理您提到的那种代码完成-例如eric

So if you can't get PyDev to do the right thing, the answer is not to switch languages, but to switch IDE's. 因此,如果您不能让PyDev做正确的事,答案不是切换语言,而是切换IDE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM