How can I create a *.ui file from a manually edited app
In Qt Creator go to File -> New File or Project -> Qt -> Qt Designer Form. Select a widget type, e.g. Widget and give the file a meaningful name (usually the same as your h/cpp file): mainwindow.ui. It will be added to you project.
Open it in the designer, select the widget and set its property objectName to match the name of your class in your h/cpp (it's not necessary but recommended to keep things in order).
In your .h file add:
namespace Ui {
class MainWindow; //this is the property `objectName` from the previous step. They need to match
}
and then a private field in your class declaration:
class MainWindow :
...
private:
Ui::MainWindow* ui; //this is again the matching name
}
in your .cpp file include the header generated by uic: #include "ui_mainwindow.h". the mainwindow part is the name of your .ui file.
in your constructor create the ui instance and setup:
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
}
in the destructor destroy the ui instance:
MainWindow::~MainWindow() {
delete ui;
}
How do I integrate external .h and .cpp files (external app)
just open your .pro file and add them to HEADERS and SOURCES variables.