简体   繁体   English

IntelliSense 在源文件中找不到定义的方法

[英]IntelliSense does not find defined methods in source file

I have c++ project in visual studio, which in only ONE class IntelliSense is not able to resolve a couple of declared methods in the header file.我在 Visual Studio 中有 C++ 项目,只有一个类 IntelliSense 无法解析头文件中的几个声明方法。 So when I try to click "go to definition" IntelliSense does not open the source file, because he cannot find the definition of the method.因此,当我尝试单击“转到定义”时,IntelliSense 不会打开源文件,因为他找不到方法的定义。

I tried already adding a cpp.hint file, with declaring macros used in these methods.我已经尝试添加一个cpp.hint文件,并声明在这些方法中使用的宏。 In other classes this helped to solve the problem, but not for this class.在其他课程中,这有助于解决问题,但不适用于本课程。 I also deleted every time the ipch folder and the *.db file.我每次也删除了ipch文件夹和*.db文件。

I already found out, that IntelliSense is able to resolve the first method declared after a public/protected/private specifier:我已经发现,IntelliSense 能够解析在 public/protected/private 说明符之后声明的第一个方法:
智能感知发现的方法

So switching the order helps IntelliSense to find it ...所以切换顺序有助于 IntelliSense 找到它...... 智能感知发现的方法

One BAD solution would be to add the public/protected/private specifier for every method, but you can imagine, that I don't want to do that.一种糟糕的解决方案是为每种方法添加公共/受保护/私有说明符,但您可以想象,我不想这样做。 I am also working with Qt5, but I don't think this is the problem here.我也在使用 Qt5,但我不认为这是这里的问题。 I also don't think that the problem relies in the code of the definitions, because it doesn't matter, which method stands first after the specifier.我也不认为问题依赖于定义的代码,因为这并不重要,哪个方法在说明符之后排在第一位。
Did someone already stumbled accross this kind of problem and knows how to solve it?是否有人已经偶然遇到了这种问题并知道如何解决它?

Thanks for all your sugesstions.感谢您的所有建议。

EDIT: It is definitly a Qt problem, when I comment out the Q_OBJECT definition in the class, IntelliSense can find all methods.编辑:这绝对是一个 Qt 问题,当我注释掉类中的Q_OBJECT定义时,IntelliSense 可以找到所有方法。 Unfortunately, I can't compile my code without it.不幸的是,没有它我无法编译我的代码。

So I was able to "solve" the problem.所以我能够“解决”这个问题。
I don't know why this happened, or why my "solution" solved it.我不知道为什么会发生这种情况,或者为什么我的“解决方案”解决了它。
I had added temporarily a method for debugging, which was defined as the first method, before the constructor.我在构造函数之前临时添加了一个调试方法,它被定义为第一个方法。 The definition of this method was also in the header file.这个方法的定义也在头文件中。
When I switched this method below the constructor, IntelliSense started to working (again) in this class.当我在构造函数下方切换此方法时,IntelliSense 开始(再次)在此类中工作。 Seems to be a bug with Qt and IntelliSense working together.似乎是 Qt 和 IntelliSense 一起工作的错误。

Old:老的:
在此处输入图片说明

New:新的:
在此处输入图片说明

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

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