Important: Please read the Qt Code of Conduct -

(Solved) GUI created form widgets suddenly not being automatically added to ui_mainwindow.h

  • The title says it all. Suddently, the new form widgets I create using the GUI editor are not being added to ui_mainwindow.h, so I cannot use the objects in my code.

    I tried Clean All -> Run qMake -> rebuild all, as the only online help I could find suggested.

    Also, currently the object Ui::MainWindow ui is only present in my MainWindow class, although it was previously also in another class. I know this can screw things up so that's why I mention it, and it may be linked to the problem. However, currently, the ui object is only a member to my MainWindow class and any new objects made by the GUI editor aren't being added properly.

    Has anybody found a cause and/or solution to this problem?

  • Moderators

    Hi, and welcome to the Qt Dev Net!

    Perhaps you've switched from composition to inheritance?

    // Composition:

    // Inheritance:

  • Hello and welcome

    Generally it sounds as if the Ui-Compiler uic is not executed. The GUI Editor (I suppose you refer to the QtDesigner) produces ui-Files which are xml-descriptions of your gui. These are then translated by the uic into C++ code (ui_xy.h files).

    Anyhow, this should have been executed when you performed all the steps you mentioned above. As to why this is apparently not executed, I can only guess. Could you post your .pro file? This is pretty much the only source of error I can think of given, that you executed make clean, qmake and make (which the steps you describe do).

    Best Soraltan

  • Thanks for the replies guys.

    I was able to solve this by pressing "ctrl+shift+w", which closed all open source files. Then, after doing clean all -> run qmake, rebuild all, I can now find the widgets in my ui object.

Log in to reply