[Qt-creator] add definition to .h ??

Leandro T. C. Melo leandro.melo at nokia.com
Wed Jun 6 09:54:03 CEST 2012


On 06/06/2012 02:00 AM, ext Cristian Tibirna wrote:
> (NOTE to moderator: this is a repost with a subscribed address, please ignore
> the precedent that is queued for moderation)
>
> Hello
>
> Is this known behavior?
>
> In QtCreator resulted from compilation of git:3de4c3d I get this behavior:
>
> a) add a method definition in a .h either
> 	- simply put definition next to declaration
> 	- make the method inline thus definition in .h required
> b) go to the declaration of another method and choose "Add definition in..."
>
> It (only) offers to add the definition to the .h file (even if the .cc exists
> and contains methods) and if I take the offer, it adds it immediately after
> the method definition from a) (potentially rendering the .h uncompilable).
>
> If I comment out the definition of a) the "Add definition in..." offers the
> .cc again.
>
> Known?

Hi,

I don't think so. I'd guess this is side effect from when the algorithm 
which finds the "best" insertion point was improved a while ago.

What we do is to try to find the definition of the nearest declaration 
from the method you are triggering the quick fix. Then it seems the 
inline one is found in your case and therefore this behavior.

I could not reproduce your issue when simply having void f() {} inside a 
class declaration with no inline members. Perhaps it happens to you 
because you still have such an inline function and no other declaration 
with the definition in the corresponding implementation file in between.

If you could please fill a report...


Cheers,
Leandro





More information about the Qt-creator mailing list