Important: Please read the Qt Code of Conduct -

[Solved] ui_*.h files generated in wrong directory

  • I noticed that I could make updates to my application and they'd work just fine except when I tried to update my GUI. I'd make a change to a form but it wouldn't reflect in the application when run.

    I did some research and found out the ui_.h files were being generated in the release directory instead of the project folder. When I move the ui_.h files into the project folder and rebuild, they're reflected in my GUI.

    I saw mention to set UI_DIR in the *.pro file but I'm not sure what to set it to. Is there a better way to fix this? If not, what do I set that value to in the *.pro file. If I set it like:
    UI_DIR = ui
    It creates a ui directory in the build directory instead of in the project directory.

    Thanks in advance.

  • Moderators

    I would think that you would want your uic-created files to live in the build directory rather than the project directory, as they are temporary files which are built at compile time for that particular build instance.

  • That makes sense. What can I do so I don't have to copy them to the project directory to get the updates when I build?

    If I don't copy the ui_*.h files to my project directory, my UI never sees the changes I make. I can change a label's text but unless I copy those files, my app still has the old text.

  • I should also mention that if I just delete the ui_*.h files from my project directory and expect the ones in the build directory to be chosen, it fails to find them at all. It just isn't looking in the build directory for these files at all.

  • Moderators

    what do your #include statements for the ui_*.h look like? Anything strange in your .pro file?

    Does re-running qmake after you make a change help things?

  • Here's the .pro file:


    Project created by QtCreator 2012-11-12T11:57:23


    QT += core gui sql

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = TheDirector
    TEMPLATE = app

    SOURCES += main.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    #UI_DIR = ui


    win32 {
    QMAKE_LFLAGS += -static
    CONFIG += -no-exceptions
    } else {

    and the includes aren't anything special. Here's the entirety of one of the .cpp files:
    @#include "editallprofiledetails.h"
    #include "ui_editallprofiledetails.h"

    EditAllProfileDetails::EditAllProfileDetails(QWidget *parent) :
    ui(new Ui::EditAllProfileDetails)

    this->AllProfileDetailsModel = new QSqlTableModel(this, QSqlDatabase::database("DirectorDB"));
    ui->tblAllProfiles->setModel( AllProfileDetailsModel );


    delete ui;

    Running qmake doesn't change anything for me. It happens the same whether I build from within Qt Creator or via the command line manually.

    Odd, huh?

  • Resources are doing the same thing to me. I can't add resources because it doesn't find them in the right directory to be linked.

    When I create a new object, I have copy files for the code-completion thing to work.

    I have workarounds but would love to know if there's a configuration option I've set wrong. I should say that this is a new install. It's not like it was working, then stopped, so it's likely something I'm doing wrong.

    It happens on my Windows and my Mac environment.

  • Moderators

    You're not, by chance, sharing the .pro.user file across platforms, are you?

  • Yes. I've been copying the directory over when I want to develop on a different machine.... That's bad, huh?

  • Moderators

    Yeah, the .pro.user file is specific to one particular instance of Creator and is not portable between systems, users, platforms, or whatever. Sharing it is a Bad Idea. Try getting rid of it and see if your problems still exist.

  • That resolved it. Thanks!

  • Moderators

    Good deal! Be sure and edit the thread title to add [Solved]. Thanks!

Log in to reply