Yay! I got it to compile and run!
OK, here is how to go from a .ui file (and only a .ui file) to a usable executable in Linux.
Step 1: Let's say your .ui file creates a color picker, in my case I called it ZarehsQtColorPicker.ui
Go to the folder where your .ui file is and type the following command:
> uic -o ZarehsQtColorPicker.h ZarehsQtColorPicker.ui
make sure you're running the correct version of uic. You can specify it's path explicitly if you need to by typing it out, in my case it was something like this: ../../Linux_x86-2010.01/qt-everywhere-opensource-src-4.6.1/bin/uic -oZarehsQtColorPicker.h ZarehsQtColorPicker.ui
At the end of this step you should have a .h file.
Step 2: You have to create a .pro file (Project file). Here is what mine looks like:
CONFIG += qt
HEADERS += ZarehsQtColorPicker.h
SOURCES += main.cpp
Just go into emacs, vi or any text editor you like and type the above 3 lines and save the file. I called my file ZarehsQtColorPicker.pro
You also need to make a main.cpp file. Here is what it should look like:
#include "ZarehsQtColorPicker.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *widget = new QWidget;
Ui::ZarehsColorPicker ui;
ui.setupUi(widget);
widget->show();
return app.exec();
}
The only things you need to change are the things colored in green. Just substitute whatever .h file and class name you are using in your example.
OK, now that you have a .pro and a main.cpp file, type this command at the command prompt, making sure you're still in the directory where your .ui and .h file is:
> qmake -o Makefile ZarehsQtColorPicker.pro
Step 3: now you should have a file called "Makefile" in your directory. At the command prompt type make.
> make
that's it. you should now have an executable file in your directory. In my case it's called ZarehsQtColorPicker. I typed
> ./ZarehsQtColorPicker
at the command prompt and it executed and brought up the GUI designed in Designer.
Hope this helps someone out there,
Zareh
Bookmarks