Code completion is not so smart.



  • I am using QT 5.4 + QTCreator 3.4.

    I found that the code completion is QT is not so smart. Once the class/struct is nested in an array/vector, or it has a template, the hint cannot be triggered. For example:

    class A
    {
    void foo(){}
    }
    A a;
    A. (then it triggers the hint "foo()")

    std::vector<A> vec_A(10);
    A[1]. (then the hint may not be triggered..)

    Actually it is not a very big deal for most previous usages, but few days ago I begin to code with CGAL (computational geometry algorithm library), and all the components of CGAL are written in template fashion. The code autocompletion is virtually useless in such scenario.

    I used to code with Visual Studio and XCode, and I remember their code completion can handle nested array and template problems. I think QT should be able to make it as well.

    I am just wondering if there is any add-in or update to enhance the code completion and make it "smarter".


  • Moderators

    Hi @itsshiwei, and welcome to the Qt Dev Net!

    Try enabling the (experimental) clang code model in Qt Creator: "Help" -> "About Plugins..." -> "C++"



  • @JKSH Thanks a lot!

    Now the code completion is much stronger. I should have known this earlier. :)



  • @JKSH by the way, I just feel that the ClangCodeModel is quite slow (takes ~3 seconds to pop up the hints). Is it working correctly?


  • Moderators

    @itsshiwei said:

    @JKSH by the way, I just feel that the ClangCodeModel is quite slow (takes ~3 seconds to pop up the hints). Is it working correctly?

    I haven't used the clang model myself so I don't know what the performance should be like. However, other users have reported that it's slow too (http://comments.gmane.org/gmane.comp.lib.qt.creator/9784 ). It is still experimental and incomplete. That's why it's not enabled by default.

    You could subscribe to the Qt-creator mailing list and post there, if you want to talk to the creators of the clang plugin. They can tell you if an updated plugin is expected soon, or if you might want to consider using Visual Studio for your CGAL projects.

    If you change your IDE, go to http://www.qt.io/download-open-source/ and click "Other Downloads" -- you will see a "Visual Studio Add-In" to integrate Qt into Visual Studio.



  • @JKSH Hi! I came across this too. I feel that it has worked for me in the past, e.g. using a simple std::vector<QString> and then expecting code completion on typing myVector[0].

    But it's not working in QtCreator 3.4.0, not even with the plugin you mentioned... Anything else I can try?

    EDIT: Nevermind, found out that I have to enable it in the preferences too... it's working but a bit slow...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.