Need some assistance with qmake
I have been reading C++ programming with Qt 4 and I am stuck as I don't understand how one uses qmake, specifically when dealing with dialogs made from Qt designer. There is a passage in the book that reads:
"Now run qmake to create a .pro file and a makefile (qmake -project; qmake gotocell.pro)". The problem is I don't know how one handles qmake when not in Qt creator. So far the book makes you create a folder called gotocell and asks you to create a main.cpp file from a plain text editor. I have done that and have placed the dialog that was created in Qt Designer (called gotocelldialog.ui) in the gotocell folder. I have tried opening the main.cpp in Qt Creator to use its built in qmake but I am unable to access Build mode from the toolbar. I have a feeling I have to use the Qt command prompt but I have been having some difficulties with it.
If anybody can help, I would appreciate it. Thanks in advance
(I have Qt 5.3)
Did you create the .pro file after creating all the necessary files. Jus open the .pro file in QtCreator. Start compiling.
I suggest you start everything in QtCreator. It will do anything easy for you. Post that you get into doing things manually.
No .pro file has not been created, the only thing in my gotocell folder is a main.cpp file and gotocelldialog.ui file that I created from Qt Designer.
The book says I have to turn the main.cpp file into a .pro file by using qmake. I have to use the following commands (qmake -project and qmake gotocell.pro). When I enter the first command in the Qt command prompt nothing happens. I have used Notepad++ to convert the main.cpp into a main.pro file. I have also used Notepad++ to create a makefile. The problem with this approach however is that I am not able to convert a gotocelldialog.ui into a ui_gotocelldialog.h because Notepad++ doesn't have uic tool, qmake on the other hand does.
- Go to the directory and run the 'qmake -project'. This creates the pro file
- Now run 'qmake'
- Now run mingw32-make.
It should go fine. I suggest you open the .pro file in Qt creator after the first step. Just work with QtCreator.
Hope this helps
Sorry, I need some clarification on something, for number 1 you said I should go to the directory and run the qmake -project, which directory are you referring to? the gotocell folder that has the main.cpp and gotocelldialog.ui? Because besides those two items there is nothing there
yes. gotocelldialog dir
You said run qmake -project, does that mean I should use the Qt command prompt because I have used it and nothing happens.
I suppose if all else fails I will redo the all thing with Qt Creator.
JKSH Moderators last edited by
That book is very old now. Much of it is still relevant, but some of its advice (running qmake manually, editing code using an external text editor, etc.) isn't considered very productive anymore. Since you are using Qt Creator, it's a lot easier to let Qt Creator take care of qmake for you.
Click File -> New File or Project... -> Applications -> Qt Widgets Application
That will set up a project folder for you. You can then follow the tutorial from within Qt Creator.
Ya, Thanks for the help Dheerendra and JKSH,
I have decided to just use Qt Creator for all my needs instead of handling qmake manually and using external editors. Too many headaches.