问题
So here is my problem. I just started studying Qt. I study from a book about Qt. There is shown how to make a simple dialog. The dialog is made with Qt Designer. The book says that when I'm done making the design in the file called gotocelldialog.ui, I need to go to main.cpp and type this:
#include <QApplication>
#include <QDialog>
#include "ui_gotocelldialog.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Ui::GoToCellDialog ui;
QDialog *dialog = new QDialog;
ui.setupUi(dialog);
dialog->show();
return app.exec();
}
It is said that when I run this witk Qmake, a header file will be generated from my gotocelldialog.ui. But the only thing that is generated is .pro file. This is its content:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp
HEADERS +=
FORMS += \
gotocelldialog.ui
I can't understand why ui_gotocelldialog.h is not generated. I'm using Qt 5.1.1 - the latest version. Can you explain me this with details because as I said I'm new to Qt and I don't know well how Qmake works. Thanks for reading.
回答1:
For Mac users, open the terminal and go to the folder where your files in, then type the following
This line will generate the .pro file
> qmake -project
This line will generate the Makefile
> qmake
This line will generate the rest of files (in your case Forms.app, main.o, and ui_gotocelldialog.h)
> make
You need gotocelldialog.ui and main.cpp in the same folder (Note: you must have only one .pro file which will be generated by "qmake -project" otherwise you need to specify the .pro file). That being said, if the problem still exists then the problem has nothing to do with qmake or Qt designer.
来源:https://stackoverflow.com/questions/20316294/qmake-doesnt-generate-a-header-file