Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. New UI widgets elements inaccessible to code model
Forum Updated to NodeBB v4.3 + New Features

New UI widgets elements inaccessible to code model

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
24 Posts 4 Posters 2.7k 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.
  • T Offline
    T Offline
    ThirdStrand
    wrote on 31 Jul 2023, 16:55 last edited by
    #1

    QtCreator 11.0.0, running MingW-64 compiler. I disable Clang Code Model by default by de-selecting the plugin. Clang is just too slow. The default code model also handles "." vs "->" on object references intelligently, so I prefer it.

    I have noticed in Qt 6.5 using CMake and the default code model (NOT Clang) that if I create a UI element in the designer pane and go back to the source code, that element is not available for code completion, and is generally just not recognized as existing to the code model.

    Complete rebuilds of the project do not fix this. It is also compounded by the same behavior if a widget element is renamed ("objectName" is changed). It is not until QtCreator is closed and restarted that the project will recognize the new UI widget objects.

    I am happy to be completely wrong and to have done a stupid human trick on the configuration somewhere, so please enlighten me. This is the first time since 2016 that I have run into this.

    Regards,
    Mitch

    1 Reply Last reply
    0
    • T Offline
      T Offline
      ThirdStrand
      wrote on 31 Jul 2023, 17:18 last edited by
      #2

      As a test of my memory, I opened an existing qmake project, added a UI widget element to the designer form and saved the .ui file.

      I went to the source code for that class and the element was immediately available to the code model for auto-completion.

      P 1 Reply Last reply 31 Jul 2023, 17:41
      0
      • T ThirdStrand
        31 Jul 2023, 17:18

        As a test of my memory, I opened an existing qmake project, added a UI widget element to the designer form and saved the .ui file.

        I went to the source code for that class and the element was immediately available to the code model for auto-completion.

        P Offline
        P Offline
        Pl45m4
        wrote on 31 Jul 2023, 17:41 last edited by
        #3

        @ThirdStrand

        Usually you have to build (so that moc/uic are executed) your project again after adding new stuff to your Designer UI file.
        I would say, the model doesn't recognize the new widget because it's simply not there. The UI code has not been translated into the usable C++ header.
        So ui->.... cant autocomplete, let's say, pushButton_1.


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        T 1 Reply Last reply 31 Jul 2023, 17:45
        0
        • P Pl45m4
          31 Jul 2023, 17:41

          @ThirdStrand

          Usually you have to build (so that moc/uic are executed) your project again after adding new stuff to your Designer UI file.
          I would say, the model doesn't recognize the new widget because it's simply not there. The UI code has not been translated into the usable C++ header.
          So ui->.... cant autocomplete, let's say, pushButton_1.

          T Offline
          T Offline
          ThirdStrand
          wrote on 31 Jul 2023, 17:45 last edited by ThirdStrand
          #4

          @Pl45m4 I would have believed you if it hadn't worked in qmake by simply saving the .ui file. I think this "issue" lives in cmake somewhere.

          P 1 Reply Last reply 31 Jul 2023, 17:53
          0
          • T ThirdStrand
            31 Jul 2023, 17:45

            @Pl45m4 I would have believed you if it hadn't worked in qmake by simply saving the .ui file. I think this "issue" lives in cmake somewhere.

            P Offline
            P Offline
            Pl45m4
            wrote on 31 Jul 2023, 17:53 last edited by Pl45m4 8 Apr 2023, 13:49
            #5

            @ThirdStrand

            In my qmake project I have to do it also.
            There is some auto-build option in your project, which the other project doesnt have?
            IIRC you can set something like "Build every time before run" in QtCreator.

            Without doing anything else, there is no way that your code model recognizes changes made to your UI file in QtDesigner...
            Whole thing works by translating the XML style UI file into a compilable C++ header. If you add something to your UI file, which is not in your header, you cant use it without rebuilding your app.
            How else should this work?!

            If you know the object name and you type it yourself, you can edit the UI, change your code and "build + run". Then it works, but you dont have model autocompletion support until you run your app at least once.


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            T 1 Reply Last reply 31 Jul 2023, 18:22
            0
            • P Pl45m4
              31 Jul 2023, 17:53

              @ThirdStrand

              In my qmake project I have to do it also.
              There is some auto-build option in your project, which the other project doesnt have?
              IIRC you can set something like "Build every time before run" in QtCreator.

              Without doing anything else, there is no way that your code model recognizes changes made to your UI file in QtDesigner...
              Whole thing works by translating the XML style UI file into a compilable C++ header. If you add something to your UI file, which is not in your header, you cant use it without rebuilding your app.
              How else should this work?!

              If you know the object name and you type it yourself, you can edit the UI, change your code and "build + run". Then it works, but you dont have model autocompletion support until you run your app at least once.

              T Offline
              T Offline
              ThirdStrand
              wrote on 31 Jul 2023, 18:22 last edited by ThirdStrand 8 Feb 2023, 16:10
              #6

              @Pl45m4 I am not saying that's not how it works internally, and what you said makes perfect sense. What I am saying is that in a qmake Widgets project, if you add a UI element, hit Ctrl+S, and go to the source for that object (Shift + F4), then you will likely see code completion for the new UI element. I always have (for 7 years) until trying to get on board with CMake.

              I have never (knowingly) changed any settings having to do with qmake in the Qt Creator Preferences. All are defaults.

              CMake is sort of a necessity by way of needing the new QProtobuf library, which uses CMake as the helper to compile the Qt style support classes for each .proto file.

              In my CMakeLists.txt file, all of the .ui files are included in a list of all of the source .cpp and .h files. So CMake knows which files are in play.

              To some it may seem that this is a trivial thing, but I switch back and forth between the UI editor and the source editor constantly as I add UI elements, then create and implement the slots for them on the spot. If the code model doesn't know about the new elements, this makes for a VERY slow process for something that is very intuitive and flows nicely when in qmake.

              Perhaps there is some "CMake magic" to make it act like qmake does. Who knows?

              P 1 Reply Last reply 1 Aug 2023, 00:28
              0
              • T ThirdStrand
                31 Jul 2023, 18:22

                @Pl45m4 I am not saying that's not how it works internally, and what you said makes perfect sense. What I am saying is that in a qmake Widgets project, if you add a UI element, hit Ctrl+S, and go to the source for that object (Shift + F4), then you will likely see code completion for the new UI element. I always have (for 7 years) until trying to get on board with CMake.

                I have never (knowingly) changed any settings having to do with qmake in the Qt Creator Preferences. All are defaults.

                CMake is sort of a necessity by way of needing the new QProtobuf library, which uses CMake as the helper to compile the Qt style support classes for each .proto file.

                In my CMakeLists.txt file, all of the .ui files are included in a list of all of the source .cpp and .h files. So CMake knows which files are in play.

                To some it may seem that this is a trivial thing, but I switch back and forth between the UI editor and the source editor constantly as I add UI elements, then create and implement the slots for them on the spot. If the code model doesn't know about the new elements, this makes for a VERY slow process for something that is very intuitive and flows nicely when in qmake.

                Perhaps there is some "CMake magic" to make it act like qmake does. Who knows?

                P Offline
                P Offline
                Pl45m4
                wrote on 1 Aug 2023, 00:28 last edited by Pl45m4 8 Jan 2023, 00:29
                #7

                @ThirdStrand said in New UI widgets elements inaccessible to code model:

                What I am saying is that in a qmake Widgets project, if you add a UI element, hit Ctrl+S, and go to the source for that object (Shift + F4), then you will likely see code completion for the new UI element.

                And that is what I find weird...

                UIFile.png

                I've added a pushButton9 to my UI file, saved, went back to mainWindow.cpp and tried to let the autocompletion recognize it... which it did not. The code compiles because there is a pushButton9 in my case, but the auto-completion model didn't know about the new widget until I compiled/built once.
                I dont know if my project settings are weird but (for me) it was always like this.
                Note: I'm not using the latest version of QtCreator


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                T 2 Replies Last reply 1 Aug 2023, 18:11
                0
                • P Pl45m4
                  1 Aug 2023, 00:28

                  @ThirdStrand said in New UI widgets elements inaccessible to code model:

                  What I am saying is that in a qmake Widgets project, if you add a UI element, hit Ctrl+S, and go to the source for that object (Shift + F4), then you will likely see code completion for the new UI element.

                  And that is what I find weird...

                  UIFile.png

                  I've added a pushButton9 to my UI file, saved, went back to mainWindow.cpp and tried to let the autocompletion recognize it... which it did not. The code compiles because there is a pushButton9 in my case, but the auto-completion model didn't know about the new widget until I compiled/built once.
                  I dont know if my project settings are weird but (for me) it was always like this.
                  Note: I'm not using the latest version of QtCreator

                  T Offline
                  T Offline
                  ThirdStrand
                  wrote on 1 Aug 2023, 18:11 last edited by
                  #8

                  @Pl45m4 Ok is this a Qt5 vs. Qt6 issue then? I tested an older Qt5 project. I'll retest with a newer Qt6 qmake project and report back.

                  T 1 Reply Last reply 1 Aug 2023, 19:28
                  0
                  • P Pl45m4
                    1 Aug 2023, 00:28

                    @ThirdStrand said in New UI widgets elements inaccessible to code model:

                    What I am saying is that in a qmake Widgets project, if you add a UI element, hit Ctrl+S, and go to the source for that object (Shift + F4), then you will likely see code completion for the new UI element.

                    And that is what I find weird...

                    UIFile.png

                    I've added a pushButton9 to my UI file, saved, went back to mainWindow.cpp and tried to let the autocompletion recognize it... which it did not. The code compiles because there is a pushButton9 in my case, but the auto-completion model didn't know about the new widget until I compiled/built once.
                    I dont know if my project settings are weird but (for me) it was always like this.
                    Note: I'm not using the latest version of QtCreator

                    T Offline
                    T Offline
                    ThirdStrand
                    wrote on 1 Aug 2023, 18:14 last edited by ThirdStrand 8 Mar 2023, 12:45
                    #9
                    This post is deleted!
                    T 1 Reply Last reply 1 Aug 2023, 19:21
                    0
                    • T ThirdStrand
                      1 Aug 2023, 18:14

                      This post is deleted!

                      T Offline
                      T Offline
                      ThirdStrand
                      wrote on 1 Aug 2023, 19:21 last edited by ThirdStrand 8 Jan 2023, 19:24
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • T ThirdStrand
                        1 Aug 2023, 18:11

                        @Pl45m4 Ok is this a Qt5 vs. Qt6 issue then? I tested an older Qt5 project. I'll retest with a newer Qt6 qmake project and report back.

                        T Offline
                        T Offline
                        ThirdStrand
                        wrote on 1 Aug 2023, 19:28 last edited by ThirdStrand 8 Jan 2023, 19:35
                        #11

                        @ThirdStrand said in New UI widgets elements inaccessible to code model:

                        @Pl45m4 Ok is this a Qt5 vs. Qt6 issue then? I tested an older Qt5 project. I'll retest with a newer Qt6 qmake project and report back.

                        So I opened a qmake project and set the kit to Qt 6.5.2. I built it. Then I opened the main UI file and added a QLabel. Ctrl + S to save, Shift + F4 to go to the source code and the code model found the QLabel immediately. Same as happened in Qt5 qmake. AND THIS HAPPENS WITH THE clangd process running.

                        I cannot believe that I am the only one who has noticed this. Not being able to have code completion when adding UI elements severely slows down creation of UI projects.

                        T 1 Reply Last reply 1 Aug 2023, 20:43
                        0
                        • T ThirdStrand
                          1 Aug 2023, 19:28

                          @ThirdStrand said in New UI widgets elements inaccessible to code model:

                          @Pl45m4 Ok is this a Qt5 vs. Qt6 issue then? I tested an older Qt5 project. I'll retest with a newer Qt6 qmake project and report back.

                          So I opened a qmake project and set the kit to Qt 6.5.2. I built it. Then I opened the main UI file and added a QLabel. Ctrl + S to save, Shift + F4 to go to the source code and the code model found the QLabel immediately. Same as happened in Qt5 qmake. AND THIS HAPPENS WITH THE clangd process running.

                          I cannot believe that I am the only one who has noticed this. Not being able to have code completion when adding UI elements severely slows down creation of UI projects.

                          T Offline
                          T Offline
                          ThirdStrand
                          wrote on 1 Aug 2023, 20:43 last edited by
                          #12

                          ...

                          I cannot believe that I am the only one who has noticed this. Not being able to have code completion when adding UI elements severely slows down creation of UI projects.

                          INTERESTING:
                          The qmake project, when viewed in the "Tools/Debug QtCreator Code Model Inspector" (Ctrl+Shift+F12) shows both of my project's UI header files (ui_classname.h) as part of the Project Files tab.

                          The cmake project with the same set of files, however, does NOT show them in the Project Files tab. If I explicitly add the ui_classname.h files to the cmake list of input files, there is no (discernable) activity when either of those two files change.

                          Next stop bug report unless someone has further information.

                          T 1 Reply Last reply 1 Aug 2023, 20:58
                          0
                          • T ThirdStrand
                            1 Aug 2023, 20:43

                            ...

                            I cannot believe that I am the only one who has noticed this. Not being able to have code completion when adding UI elements severely slows down creation of UI projects.

                            INTERESTING:
                            The qmake project, when viewed in the "Tools/Debug QtCreator Code Model Inspector" (Ctrl+Shift+F12) shows both of my project's UI header files (ui_classname.h) as part of the Project Files tab.

                            The cmake project with the same set of files, however, does NOT show them in the Project Files tab. If I explicitly add the ui_classname.h files to the cmake list of input files, there is no (discernable) activity when either of those two files change.

                            Next stop bug report unless someone has further information.

                            T Offline
                            T Offline
                            ThirdStrand
                            wrote on 1 Aug 2023, 20:58 last edited by
                            #13

                            @ThirdStrand said in New UI widgets elements inaccessible to code model:

                            ...

                            I cannot believe that I am the only one who has noticed this. Not being able to have code completion when adding UI elements severely slows down creation of UI projects.

                            INTERESTING:
                            ...

                            Next stop bug report unless someone has further information.

                            If clangd is turned off completely (confirmed not even running on the PC), the same behavior remains. Works in qmake, and doesn't work in cmake. This may have something to do with cmake and AUTOUIC perhaps????????

                            P 1 Reply Last reply 1 Aug 2023, 21:42
                            0
                            • T ThirdStrand
                              1 Aug 2023, 20:58

                              @ThirdStrand said in New UI widgets elements inaccessible to code model:

                              ...

                              I cannot believe that I am the only one who has noticed this. Not being able to have code completion when adding UI elements severely slows down creation of UI projects.

                              INTERESTING:
                              ...

                              Next stop bug report unless someone has further information.

                              If clangd is turned off completely (confirmed not even running on the PC), the same behavior remains. Works in qmake, and doesn't work in cmake. This may have something to do with cmake and AUTOUIC perhaps????????

                              P Offline
                              P Offline
                              Pl45m4
                              wrote on 1 Aug 2023, 21:42 last edited by
                              #14

                              Hm... maybe somebody else will comment on this whole thing and possibly can reproduce it. Could be some weird config, could be a bug or some unhandled behavior...
                              Good luck ;-)


                              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                              ~E. W. Dijkstra

                              T 1 Reply Last reply 2 Aug 2023, 12:03
                              0
                              • P Pl45m4
                                1 Aug 2023, 21:42

                                Hm... maybe somebody else will comment on this whole thing and possibly can reproduce it. Could be some weird config, could be a bug or some unhandled behavior...
                                Good luck ;-)

                                T Offline
                                T Offline
                                ThirdStrand
                                wrote on 2 Aug 2023, 12:03 last edited by
                                #15

                                Yes, I am of the same hopes. Bear in mind also that this is a fresh Win11Pro PC, a freshly installed QtCreator 11.0.0 and the universal installer downloaded and installed all of the kits. Totally stock standard Qt.

                                1 Reply Last reply
                                0
                                • Christian EhrlicherC Christian Ehrlicher moved this topic from General and Desktop on 2 Aug 2023, 13:04
                                • T Offline
                                  T Offline
                                  ThirdStrand
                                  wrote on 3 Aug 2023, 13:45 last edited by
                                  #16

                                  @Christian-Ehrlicher Thanks for moving this topic around in attempts to get visibility. Much appreciated.

                                  1 Reply Last reply
                                  0
                                  • T Offline
                                    T Offline
                                    ThirdStrand
                                    wrote on 3 Aug 2023, 16:54 last edited by
                                    #17

                                    For the record as no noise here yet:

                                    https://bugreports.qt.io/browse/QTCREATORBUG-29465

                                    JonBJ 1 Reply Last reply 3 Aug 2023, 17:51
                                    0
                                    • T ThirdStrand
                                      3 Aug 2023, 16:54

                                      For the record as no noise here yet:

                                      https://bugreports.qt.io/browse/QTCREATORBUG-29465

                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on 3 Aug 2023, 17:51 last edited by
                                      #18

                                      @ThirdStrand Have you noticed it is marked "Duplicate" of https://bugreports.qt.io/browse/QTCREATORBUG-28787 ?

                                      1 Reply Last reply
                                      0
                                      • T Offline
                                        T Offline
                                        ThirdStrand
                                        wrote on 3 Aug 2023, 18:22 last edited by
                                        #19

                                        and ::

                                        https://bugreports.qt.io/browse/QTCREATORBUG-28787

                                        appears to have been reported this past February.

                                        1 Reply Last reply
                                        0
                                        • cristian-adamC Offline
                                          cristian-adamC Offline
                                          cristian-adam
                                          wrote on 4 Aug 2023, 13:47 last edited by
                                          #20

                                          The CMake project using AUTOUIC set to ON do not work.

                                          But if you don't use AUTOUIC it works as expected.

                                          I've changed a hello-widgets-cmake project like this:

                                          #set(CMAKE_AUTOUIC ON)
                                          
                                          qt_wrap_ui(UI_SRC mainwindow.ui)
                                          
                                          set(PROJECT_SOURCES
                                                  main.cpp
                                                  mainwindow.cpp
                                                  mainwindow.h
                                                  ${UI_SRC}
                                          )
                                          target_include_directories(hello-widgets-cmake PRIVATE ${CMAKE_BINARY_DIR})
                                          

                                          And got it working for me.

                                          T 1 Reply Last reply 4 Aug 2023, 15:29
                                          0

                                          1/24

                                          31 Jul 2023, 16:55

                                          • Login

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