[Qt-creator] Follow Symbol Under Cursor always takes me to the header file

Adam Light aclight at gmail.com
Fri Feb 19 15:42:51 CET 2021


On Thu, Feb 18, 2021 at 3:04 PM Michael Jackson <mike.jackson at bluequartz.net>
wrote:

> I have a .cpp file opened. I am sitting at a piece of code and I want to
> jump to the method definition, I right click and select "Follow Symbol
> Under Cursor", QtCreator takes me to the "declaration" in the header file.
> How do I get it to jump to the definition instead?
>
> As a side note: This has *never* worked for me since I have started using
> QtCreator. I just put up with it. But this has got to be a "user error" on
> my part but I can't figure out what should be doing instead. 
>
>
This happens to us in some places in our code where the declaration and the
definition of a function are not identical.

For example, the .h file has:
void foo(QWidget* w);

and the  .cpp file has:
void foo(QWidgetPtr w);

somewhere in our code (though perhaps not in a place that the .h file
#includes) there is a typedef that defines QWidgetPtr as QWidget*,
therefore the code compiles.

If we change the types to be the same in the .h and .cpp file, then Follow
Symbol Under Cursor works as expected. But otherwise it only takes us to
the .h file.

If it's never worked for you then this is probably not what you're running
into, but I thought I'd mention this just in case.

Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20210219/6d718e6a/attachment.html>


More information about the Qt-creator mailing list