Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Creator autocomplete fails to work with ui
Forum Updated to NodeBB v4.3 + New Features

Qt Creator autocomplete fails to work with ui

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    umod.47
    wrote on last edited by
    #1

    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.

    Press ESCAPE to enter or ENTER to escape.
    Keyboard not found. Press F1 to continue.
    (c) BIOS

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Does it get better once you compiled your application ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • U Offline
        U Offline
        umod.47
        wrote on last edited by
        #3

        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?

        Press ESCAPE to enter or ENTER to escape.
        Keyboard not found. Press F1 to continue.
        (c) BIOS

        1 Reply Last reply
        0
        • U Offline
          U Offline
          umod.47
          wrote on last edited by
          #4

          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

          Press ESCAPE to enter or ENTER to escape.
          Keyboard not found. Press F1 to continue.
          (c) BIOS

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            U 1 Reply Last reply
            0
            • SGaistS SGaist

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

              U Offline
              U Offline
              umod.47
              wrote on last edited by
              #6

              @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

              Press ESCAPE to enter or ENTER to escape.
              Keyboard not found. Press F1 to continue.
              (c) BIOS

              1 Reply Last reply
              0
              • U Offline
                U Offline
                umod.47
                wrote on last edited by umod.47
                #7

                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
                

                Press ESCAPE to enter or ENTER to escape.
                Keyboard not found. Press F1 to continue.
                (c) BIOS

                1 Reply Last reply
                0
                • U Offline
                  U Offline
                  umod.47
                  wrote on last edited by umod.47
                  #8

                  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.

                  Press ESCAPE to enter or ENTER to escape.
                  Keyboard not found. Press F1 to continue.
                  (c) BIOS

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SOHAM889
                    wrote on last edited by
                    #9

                    For me the solution was :
                    1.Selecting MSVC compiler instead of MinGW.
                    or
                    2. Forced Enabling clangd which was disabled due to my low ram.
                    After that everything worked like charm

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved