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. QtCreator: Project fails to build after renaming an object.
QtWS25 Last Chance

QtCreator: Project fails to build after renaming an object.

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
9 Posts 4 Posters 3.3k Views
  • 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.
  • J Offline
    J Offline
    J0J0
    wrote on last edited by
    #1

    Hi, I am still having trouble with creator.

    What I did: I renamed one of my header files. In order to accomplish this, I right-moused the file in the project view and chose "Rename..." to rename it from "oldHeader.h" to "newHeader.h". This appeared to work.

    This renaming was some days ago, and now I renamed some object in the object inspector by rightMouse->"Change objectName..." This renamed the object as intended, but ui_mainwindow.h now throws a compile error because of #include "oldHeader.h".

    Of course, oldHeader.h has been renamed to newHeader.h so ui is using the wrong, old name. As far as I understand the "ui" stuff is auto-generated, hence it's pointless to fix ui_mainwindow.h by hand...

    How can I fix this?

    QtCreator: 3.5.1
    Qt: 5.5.1
    OS: x86_64-linux-gnu, Ubuntu 16.04.2 LTS "xenial"
    Compiler: GCC v5.2.1

    K 1 Reply Last reply
    0
    • J J0J0

      Hi, I am still having trouble with creator.

      What I did: I renamed one of my header files. In order to accomplish this, I right-moused the file in the project view and chose "Rename..." to rename it from "oldHeader.h" to "newHeader.h". This appeared to work.

      This renaming was some days ago, and now I renamed some object in the object inspector by rightMouse->"Change objectName..." This renamed the object as intended, but ui_mainwindow.h now throws a compile error because of #include "oldHeader.h".

      Of course, oldHeader.h has been renamed to newHeader.h so ui is using the wrong, old name. As far as I understand the "ui" stuff is auto-generated, hence it's pointless to fix ui_mainwindow.h by hand...

      How can I fix this?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @J0J0

      Do you have used the renamed/old header file in promoting a widget or similar?

      AFAIK you need to go through the promotion step in designer again (bascially removing the promotion and repromoting).
      Possibly you can change the *.ui with another editor as proposed by in the other post ny @mrjj.
      Note, better use code tracking when doing this.

      Vote the answer(s) that helped you to solve your issue(s)

      J 1 Reply Last reply
      1
      • K koahnig

        @J0J0

        Do you have used the renamed/old header file in promoting a widget or similar?

        AFAIK you need to go through the promotion step in designer again (bascially removing the promotion and repromoting).
        Possibly you can change the *.ui with another editor as proposed by in the other post ny @mrjj.
        Note, better use code tracking when doing this.

        J Offline
        J Offline
        J0J0
        wrote on last edited by
        #3

        @koahnig

        What does NOT work is patching the XML in mainwindow.ui by hand; it will be overridden again when I do some unrelated changes to the form.

        mainwindow.ui contained 2 entries

        <header>oldHeader.h</header>
        

        which I renamed by hand to

        <header>newHeader.h</header>
        

        After storing I could build the project again, but after some unrelated changes (like adding new components to the form) the oldHeader.h entries popped up again.

        QtCreator: 3.5.1
        Qt: 5.5.1
        OS: x86_64-linux-gnu, Ubuntu 16.04.2 LTS "xenial"
        Compiler: GCC v5.2.1

        J 1 Reply Last reply
        0
        • J J0J0

          @koahnig

          What does NOT work is patching the XML in mainwindow.ui by hand; it will be overridden again when I do some unrelated changes to the form.

          mainwindow.ui contained 2 entries

          <header>oldHeader.h</header>
          

          which I renamed by hand to

          <header>newHeader.h</header>
          

          After storing I could build the project again, but after some unrelated changes (like adding new components to the form) the oldHeader.h entries popped up again.

          J Offline
          J Offline
          J0J0
          wrote on last edited by
          #4

          RRR

          I don't understand this scrap!

          1. When I grep for oldHeader.h I am getting 2 entries in mainwindow.ui

          2. Changing these by hand with some editor like emacs to "newHeader.h".

          3. After storing, QtCreator propts me for changes of mainwindow.ui outside of the GUI and whether I want to load these changes.

          4. I agree to load my changes.

          5. Project builds file

          6. Drag a new component onto the form

          7. Project fails to built because missing oldHeader.h.

          8. Goto 1)

          QtCreator: 3.5.1
          Qt: 5.5.1
          OS: x86_64-linux-gnu, Ubuntu 16.04.2 LTS "xenial"
          Compiler: GCC v5.2.1

          J 1 Reply Last reply
          0
          • J J0J0

            RRR

            I don't understand this scrap!

            1. When I grep for oldHeader.h I am getting 2 entries in mainwindow.ui

            2. Changing these by hand with some editor like emacs to "newHeader.h".

            3. After storing, QtCreator propts me for changes of mainwindow.ui outside of the GUI and whether I want to load these changes.

            4. I agree to load my changes.

            5. Project builds file

            6. Drag a new component onto the form

            7. Project fails to built because missing oldHeader.h.

            8. Goto 1)

            J Offline
            J Offline
            J0J0
            wrote on last edited by
            #5
            1. Project builds file

            Should read "5) Project builds fine"

            QtCreator: 3.5.1
            Qt: 5.5.1
            OS: x86_64-linux-gnu, Ubuntu 16.04.2 LTS "xenial"
            Compiler: GCC v5.2.1

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

              hi
              if you used promotion feature, that is also written inside the UI file.

              I have no issue changing stuff in the UI file as it IS the form. its absolute.

              However, i did have a few cases where my manual changes would be overwritten if
              files also UI also open in creator.

              Also it can be stupid to recreate all moc_files again,
              so i often delte whole build folder after manual update so nothing can remain.

              I had used promotion on 12 forms and then tried to alter class name. BOOM.
              but was able to fix.
              I wish it would ask to replace in UI files too.

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

                @mrjj said in QtCreator: Project fails to build after renaming an object.:

                I wish it would ask to replace in UI files too.

                You should file a bug report for this. I guess it will require the same handling as https://bugreports.qt.io/browse/QTCREATORBUG-7044 so maybe they can be fixed together :)

                Qt has to stay free or it will die.

                J 1 Reply Last reply
                1
                • aha_1980A aha_1980

                  @mrjj said in QtCreator: Project fails to build after renaming an object.:

                  I wish it would ask to replace in UI files too.

                  You should file a bug report for this. I guess it will require the same handling as https://bugreports.qt.io/browse/QTCREATORBUG-7044 so maybe they can be fixed together :)

                  J Offline
                  J Offline
                  J0J0
                  wrote on last edited by
                  #8

                  What works for me is:

                  -- close QtCreator

                  -- Goto shell, use grep + emacs to fix the scrap left behind by creator

                  -- open QtCreator again

                  I had to use this "design process" also after renaming a button object in creator: It didn't adjust the corresponding onClick event properly, so there was left-over scrap that I could only remove by hand.

                  Sincerely, my only GUI creator experience if from a software that is 20 years old (in words: twenty years) and was released around 1998, namely Borland C++ Builder v3. All this worked like a charm and the GUI was much more intuitive. I was never in the embarrising situation of asking friends to "vote for a bug" to get it fixed...

                  QtCreator: 3.5.1
                  Qt: 5.5.1
                  OS: x86_64-linux-gnu, Ubuntu 16.04.2 LTS "xenial"
                  Compiler: GCC v5.2.1

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

                    @J0J0 said in QtCreator: Project fails to build after renaming an object.:

                    I was never in the embarrising situation of asking friends to "vote for a bug" to get it fixed...

                    Well, who will fix a bug he is not aware of? So we have to report them for sure.

                    All this worked like a charm and the GUI was much more intuitive.

                    The problem in Creator is, that the Widget Designer is in fact a separate program which Creator embeds. This leads to several small problems, like the ones you encounter. But honestly: How often do you rename a button.

                    And I can compare Creator with C++ Builder (6.0), because I'm using both. But I try to avoid using C++ Builder as it is really a pain to work with once you had something much better.

                    Qt has to stay free or it will die.

                    1 Reply Last reply
                    2

                    • Login

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