QtCreator: Project fails to build after renaming an object.



  • 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?


  • Moderators

    @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.



  • @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.



  • 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)



    1. Project builds file

    Should read "5) Project builds fine"


  • Qt Champions 2016

    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.



  • @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 :)



  • 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...



  • @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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.