Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Creator autocomplete fails to work with ui



  • I'm using Qt Creator 4.6 on Linux.
    Let's say, I've created a GUI application with a single label. I'm trying to change some text on that label. It is expected to work like this:

    ui.
    (autocomplete)
    ui->label.
    (autocomplete)
    ui->label-> (long_list_of_methods).

    However, my Qt Creator can autocomplete ui->label, but won't go further.
    Sometimes label's autocomplete works, but if I open .ui in designer and gp back to code, it stops working.
    I've tried to reinstall Qt Creator, clear Qt's cache in .config/QtProject, use a different version of Qt Creator (4.3) but it won't help. Still, autocomplete won't work beyond ui object.

    So I'm left without Qt Creator's killer feature, that used to work in previous versions on the same machine.

    $ qmake --version
    QMake version 3.1
    Using Qt version 5.10.1 in /usr/lib
    
    $ qtcreator -version
    Qt Creator 4.6.0 based on Qt 5.10.1
    

    What else should I try to fix this?
    Thanks.


  • Lifetime Qt Champion

    Hi,

    Does it get better once you compiled your application ?



  • Sometimes it is, but then it stops working again.
    BTW, if I open ui_mainwindow.h, QtCreator won't highlight objects created there (i.e. QLabel is grey where it should be green). And Ctrl+Click on class names in that file won't bring me to the class's definition.

    Maybe this is related to designer plugin somehow?



  • Some update.
    I've updated Qt Creator to 4.6.1 with the same Qt version.
    I've tried the same with CMake build system.
    Everything works, but I have to rebuild the project and reopen ui_mainwindow.h to make autocomplete work. Not very handy, but still usable, because I can enable ui autocomplete with CMake project.
    But I still can't make ui autocomplete work with qmake project on the same setup.

    Qt Creator on windows works fine with Qt 5.10


  • Lifetime Qt Champion

    Some improvements :)
    Thanks for the feedback !
    What code model are you using ?



  • @SGaist I guess default one :) I didn't specify anything.
    CLang code model is disabled. I've tried to enable it with the same result: no ui autocomplete.

    Looks like QMake project ignores ui_mainwindow.h and tries to figure out autocomplete directly from mainwindow.ui, but something goes wrong.
    CMake project doesn't know about interconnection between mainwindow.cpp and mainwindow.ui, so in depends on ui_mainwindow.h to figure out what ui object is and what it is made of.

    Here is the project I used for tests: http://umod47.ru/qtacplt.zip



  • Updated to Qt Creator 4.7.1.
    The problem is still there.
    However, now CLangCodeModel is enabled by default in modules, it seems to work somehow (although it requires me to rebuild the project to see new ui components in autocomplete).
    But CLangCodeModel doesn't understand when I want to redefine method of the superclass in header file, and fails to autocomplete something like eventFilter.

    Strange, everything used to work brilliantly a major version ago and now everything is improved and fails to work.

    EDIT: SIGNAL and SLOT macro don't work as well. I.e.:

    QTimer* t = new QTimer(this);
    connect(t, SIGNAL() ...)
                      ^ <-- Ctrl+ Space does nothing
    


  • Qt Creator 4.8.1 has no improvements :(
    CLang code model doesn't work with Qt additions.
    Without CLang code model, ui autocompletion doesn't work.
    Qt Creator 4.7.0 on Windows works flawlessly.

    i'm able to add autocompletion without CLang if I add

    #include <QLabel>
    

    Then

    ui->label->(CTRL+SPACE)
    

    works. But it's stupid to include every class that is already included in ui.


Log in to reply