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. changing objectName in design view does not update names in mainwindow.cpp
Forum Updated to NodeBB v4.3 + New Features

changing objectName in design view does not update names in mainwindow.cpp

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 6.8k 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.
  • A arif_sohaib

    Thanks for the response and sorry for the late reply.
    Yes, I am using a .pro file as well as a .pri file to include OpenCV.

    I agree about the stalling thing, it should have renamed it immediately. I have used Visual Studio in the past and it does this with its UI tools.

    Another interesting thing I found is, the names are the default ones in the ui_mainwindow.h file and changing them manually does not work.
    i.e. I still see lines like:
    lineEdit->setObjectName(QStringLiteral("lineEdit"));
    lineEdit_2->setObjectName(QStringLiteral("lineEdit_2"));
    and try to change it manually but the new names are still not recognized.

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #4

    @arif_sohaib
    hi
    Ok, could it be possible you have copied files around at some point
    and have 2 ui_mainwindow.h ?

    if you delete ui_mainwindow.h , is it generated again ?

    If you manually change the names in ui_mainwindow.h and its not changed back when you compile and
    its not seen in .cpp , it must be another one being linked to project or there is 2 of them or something like that.

    1 Reply Last reply
    2
    • A Offline
      A Offline
      arif_sohaib
      wrote on last edited by
      #5

      I just made another project starting from scratch and it now works.
      Thanks for the help

      A 1 Reply Last reply
      2
      • A arif_sohaib

        I just made another project starting from scratch and it now works.
        Thanks for the help

        A Offline
        A Offline
        arif_sohaib
        wrote on last edited by
        #6

        I had run into one more problem that others looking at this thread might want a solution to.
        After building and running the program, I added a checkBox widgit and it was not showing up in code. This was the same thing as was happening before. I deleted the ui_mainwindow.h file and then it started working.
        So it looks like the problem was that qmake was not rebuilding the ui_mainwindow.h file after updates to the display unless its old version is deleted. I am not sure if this is the intended behavior or if it is my settings but if it is the normal behavior, this could turn a lot of people away from using Qt and needs to be fixed.

        mrjjM aha_1980A 2 Replies Last reply
        0
        • A arif_sohaib

          I had run into one more problem that others looking at this thread might want a solution to.
          After building and running the program, I added a checkBox widgit and it was not showing up in code. This was the same thing as was happening before. I deleted the ui_mainwindow.h file and then it started working.
          So it looks like the problem was that qmake was not rebuilding the ui_mainwindow.h file after updates to the display unless its old version is deleted. I am not sure if this is the intended behavior or if it is my settings but if it is the normal behavior, this could turn a lot of people away from using Qt and needs to be fixed.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #7

          @arif_sohaib
          Hi
          Its not normal at all.
          I use Designer all day and renaming anything is available at once
          via UI-> with no action on my part.

          Did you change/use shadow build folder or did anything special with the ui_xxx files ?

          Also check that you dont have a virus scanner blocking the files in the build folder.
          Especially if you are using Avast.

          A 1 Reply Last reply
          3
          • A arif_sohaib

            I had run into one more problem that others looking at this thread might want a solution to.
            After building and running the program, I added a checkBox widgit and it was not showing up in code. This was the same thing as was happening before. I deleted the ui_mainwindow.h file and then it started working.
            So it looks like the problem was that qmake was not rebuilding the ui_mainwindow.h file after updates to the display unless its old version is deleted. I am not sure if this is the intended behavior or if it is my settings but if it is the normal behavior, this could turn a lot of people away from using Qt and needs to be fixed.

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by aha_1980
            #8

            @arif_sohaib,

            as @mrjj said, this usually works out of the box.

            one more idea: usually you don't open the generated ui_*.h files. if you do, you may be hit by a Clang bug that forbids updating the file.

            so if you have Clang Code Model enabled, you could check if it works if you don't open the generated files.

            Qt has to stay free or it will die.

            A 1 Reply Last reply
            2
            • mrjjM mrjj

              @arif_sohaib
              Hi
              Its not normal at all.
              I use Designer all day and renaming anything is available at once
              via UI-> with no action on my part.

              Did you change/use shadow build folder or did anything special with the ui_xxx files ?

              Also check that you dont have a virus scanner blocking the files in the build folder.
              Especially if you are using Avast.

              A Offline
              A Offline
              arif_sohaib
              wrote on last edited by
              #9

              @mrjj said in changing objectName in design view does not update names in mainwindow.cpp:

              Did you change/use shadow build folder or did anything special with the ui_xxx files ?
              Also check that you dont have a vir

              I tried with both Shadow Build on and off. I also changed the build folder because under the default settings, it wasn't able to find the .exe file when I hit run so I changed it to "project folder/build" and it started working.
              As for virus scanner, I only have the default Windows Defender.

              1 Reply Last reply
              0
              • aha_1980A aha_1980

                @arif_sohaib,

                as @mrjj said, this usually works out of the box.

                one more idea: usually you don't open the generated ui_*.h files. if you do, you may be hit by a Clang bug that forbids updating the file.

                so if you have Clang Code Model enabled, you could check if it works if you don't open the generated files.

                A Offline
                A Offline
                arif_sohaib
                wrote on last edited by
                #10

                @aha_1980 said in changing objectName in design view does not update names in mainwindow.cpp:

                one more idea: usually you don't open the generated ui_*.h files. if you do, you may be hit by a Clang bug that forbids updating the file.

                I know not to touch generated files, and I don't for anything important, but I was just experimenting with getting it to work.
                I am not sure about Clang, I am not sure. I am using the Visual Studio 2017 15 C++ compiler. Most things that I didn't mention are on their default settings.
                And thanks for the reply.

                1 Reply Last reply
                0
                • aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by aha_1980
                  #11

                  @arif_sohaib

                  sorry for being so unspecific, I had QTCREATORBUG-15449 in mind.

                  you can check with Help > About Plugins if Clang Code Model is enabled.

                  Regards

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  2
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #12

                    Hi
                    That is very strange.
                    if you manually delete the ui_ file and compile it works every time ?

                    if you are using qmake, it normally call the UI tool correctly
                    http://doc.qt.io/qt-5/uic.html

                    Its just Creator + visual studio compiler and nothing special extra?

                    1 Reply Last reply
                    2
                    • A Offline
                      A Offline
                      arif_sohaib
                      wrote on last edited by
                      #13

                      After the application compiled the first time alone with allowing adding more ui widgits, adding more widgits and compiling isn't causing any more problems.
                      Now any ui elements I add immediately show up in the mainwindow.cpp file without any additional steps.

                      mrjjM 1 Reply Last reply
                      1
                      • A arif_sohaib

                        After the application compiled the first time alone with allowing adding more ui widgits, adding more widgits and compiling isn't causing any more problems.
                        Now any ui elements I add immediately show up in the mainwindow.cpp file without any additional steps.

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #14

                        @arif_sohaib
                        Ok super. Not sure what was up with it :)

                        1 Reply Last reply
                        1

                        • Login

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