Howto UIC a UI-File created with the Qt2-Designer

Spice
Hi,

i´m working with the micro2440 and the pre-installed environment Qtopia
2.2.0 and i have compiled and installed  arm-qtopia and x86-qtopia on my
Host (Ubuntu 9.x). Now I have created a new hello world form with the
qt2-Designer located in the ../qt2/bin folder. I´ve got a .ui file and I
tried to compile it with uic to get the corresponding source-files. But I´m
struggeling at this point. In my shell, uic shows me the code of the
converted header file, but how to get this code into a header or cpp-file,
or how to work with this code or header file?   
what i had to do, to get a basic formcode created with the qt2 designer and
uic. I´m able to complile both hello-Forms delivered with the qtopia
packages, but i can´t create it on my own with the qt2-designer. Does
anybody have some links or tutorials about that?  
Thank u very much for your help
Spice

Jürgen Reche
Attachment: Makefile (4.38 KB)
here is a Makefile that you can take as a template for building an qtopia
2.2. app. It's not perfect, but includes most of the steps needed making a
app running under qtopia like building the app, calling designer 2.0 (most
a newer one is in hosts PATH), install all the acessories for a app,
translating.
This template assumes you have a main window derived from QMainWindow, a
Dialog derived from QDialog and designed by qt's designer and a main
function in qtopia-style.
"make run" starts x86-qtopia, not the app, "make arm" creates your prog for
your mini. Do a "make clean" before "make arm"

hope this help

skip

Spice
Hey Skip,

ich sehe, du solltest auch Deutsch können :-) 
vielen dank erstmal für deine Mühe, allerdings fehlen mir als Linux
quereinsteiger ein paar Kenntnisse. Ich beschreib mal was ich bis jetzt
gemacht hab. Zunächst habe ich mit ..bin/designer ein ui-file angelegt. 
Anschließend habe ich mit UIC aus dem ui-file eine test.h und eine test.cpp
erzeugt. Anschließend habe ich folgenden Code in testmain.cpp  eingefügt
und abgespeichert:

#include <qapplication.h>
#include "test.h"

int main( int argc, char* argv[] )
{
  QApplication app( argc, argv );

  Form1 form;
  app.setMainWidget( &form );
  form.show();

  int ret = app.exec();
  return ret;
}

Nun zu deinem Makefile.
progname ist geändert. Muss ich nun überall deine MainWindow.x Einträge mit
test.x und die main.x mit testmain.x ersetzen? Woher bekomme ich eigentlich
die *.pro files? Muss ich die selbst erzeugen? Braucht der Compiler diese
Datei? 
Mich machts ein wenig stutzig ob mein testmain.cpp korrekt ist, weil es ja
schon anders aussieht als im hello-Example, aber im Qt2 tutorial wurde das
unter x68 so gemacht. Ich möchte einfach nur eine Basis App für eigene
Zwecke schaffen. Aber irgendwie habe ich das gefühl, dass die sache mit dem
"kreuz- und querkompilieren" schwieriger ist für einen LinuxAnfänger als
das programmieren an sich. Ich würde mich sehr freuen, wenn du mir
dahingehend helfen könntest.     
Vielen Dank nochmal und Gruß
Spice

Spice
Irgendwie kompiliert er nicht richtig. Vermutlich sind die von uic
erzeugten dateien schon irgendwie vermurxt. ich hänge die dateien mal an.

hier die test.h
/****************************************************************************
** Form interface generated from reading ui file 'test.ui'
**
** Created: Sat Mar 20 00:49:28 2010
**      by:  The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef FORM1_H
#define FORM1_H

#include <qvariant.h>
#include <qwidget.h>
class QVBoxLayout; 
class QHBoxLayout; 
class QGridLayout; 
class QPushButton;

class Form1 : public QWidget
{ 
    Q_OBJECT

public:
    Form1( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
    ~Form1();

    QPushButton* PushButton1;

};

#endif // FORM1_H


und hier die test.cpp

/****************************************************************************
** Form implementation generated from reading ui file 'test.ui'
**
** Created: Sat Mar 20 00:49:29 2010
**      by:  The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "test.h"

#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>

/* 
 *  Constructs a Form1 which is a child of 'parent', with the 
 *  name 'name' and widget flags set to 'f' 
 */
Form1::Form1( QWidget* parent,  const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
    if ( !name )
  setName( "Form1" );
    resize( 596, 480 ); 
    setCaption( tr( "Form1" ) );

    PushButton1 = new QPushButton( this, "PushButton1" );
    PushButton1->setGeometry( QRect( 410, 80, 123, 35 ) ); 
    PushButton1->setText( tr( "Ertan" ) );
}

/*  
 *  Destroys the object and frees any allocated resources
 */
Form1::~Form1()
{
    // no need to delete child widgets, Qt does it all for us
}

Spice
Irgendwie bekomme ich beim kompilieren probleme, wenn ich zu der stelle
komme, wo die sache mit den moc_.... losgeht.
In dem HelloExample ist in der hello.h eine weitere headerdatei namens
hello_base.h includiert. Wo liegt diese Datei, wofür benötigt man die? ich
bekomme meiner meinung nach fehler beim kompilieren, weil in meinem code
genau diese Zeile fehlt. hier mal ein output vom kompilieren, vielleicht
kann mir jemand helfen. 
Ich habe eine .ui erzeugt und eine .pro geschrieben, wie im example. Dann
habe ich mittels uic die quelldateien erzeugt und mittels qmake das
Makefile. 
Danke und Gruß

/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qt2/bin/moc
.ui/release-shared/test_base.h -o .moc/release-shared/moc_test_base.cpp
arm-linux-g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -Os 
-DQT_NO_QWS_VFB -DQTOPIA_DATA_LINKING -DQCONFIG=\"qconfig-qpe.h\"
-DQTOPIA_TARGET=\"test\" -DQTOPIA_TRTARGET=\"test\" -DQT_NO_DEBUG
-I/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qtopia/mkspecs/q
ws/linux-arm-g++
-I. -I../qtopia-2.2.0-FriendlyARM/qtopia/include
-I../qtopia-2.2.0-FriendlyARM/qt2/include -I.ui/release-shared/
-I.moc/release-shared/ -o .obj/release-shared/moc_test_base.o
.moc/release-shared/moc_test_base.cpp
test -d
/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qtopia/bin/
|| mkdir -p
/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qtopia/bin/
arm-linux-g++  -o
/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qtopia/bin/test
.obj/release-shared/test.o .obj/release-shared/main.o
.obj/release-shared/test_base.o .obj/release-shared/moc_test.o
.obj/release-shared/moc_test_base.o   -luuid -lqtopia2 -lqtopia -lqpe
-L/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qtopia/lib
-L/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qt2/lib
-lqte 
.obj/release-shared/test_base.o: In function `non-virtual thunk to
Form1::~Form1()':
test_base.cpp:(.text+0x0): multiple definition of `non-virtual thunk to
Form1::~Form1()'
.obj/release-shared/test.o:test.cpp:(.text+0x0): first defined here
.obj/release-shared/test_base.o: In function `Form1::~Form1()':
test_base.cpp:(.text+0x8): multiple definition of `Form1::~Form1()'
.obj/release-shared/test.o:test.cpp:(.text+0x8): first defined here
.obj/release-shared/test_base.o: In function `Form1::~Form1()':
test_base.cpp:(.text+0x34): multiple definition of `Form1::~Form1()'
.obj/release-shared/test.o:test.cpp:(.text+0x34): first defined here
.obj/release-shared/test_base.o: In function `non-virtual thunk to
Form1::~Form1()':
test_base.cpp:(.text+0x60): multiple definition of `non-virtual thunk to
Form1::~Form1()'
.obj/release-shared/test.o:test.cpp:(.text+0x60): first defined here
.obj/release-shared/test_base.o: In function `Form1::~Form1()':
test_base.cpp:(.text+0x68): multiple definition of `Form1::~Form1()'
.obj/release-shared/test.o:test.cpp:(.text+0x68): first defined here
.obj/release-shared/test_base.o: In function `Form1::Form1(QWidget*, char
const*, unsigned int)':
test_base.cpp:(.text+0x9c): multiple definition of `Form1::Form1(QWidget*,
char const*, unsigned int)'
.obj/release-shared/test.o:test.cpp:(.text+0x9c): first defined here
.obj/release-shared/test_base.o: In function `Form1::Form1(QWidget*, char
const*, unsigned int)':
test_base.cpp:(.text+0x1ac): multiple definition of `Form1::Form1(QWidget*,
char const*, unsigned int)'
.obj/release-shared/test.o:test.cpp:(.text+0x1ac): first defined here
.obj/release-shared/moc_test_base.o: In function `Form1::className()
const':
moc_test_base.cpp:(.text+0x0): multiple definition of `Form1::className()
const'
.obj/release-shared/moc_test.o:moc_test.cpp:(.text+0x0): first defined here
.obj/release-shared/moc_test_base.o: In function
`Form1::staticMetaObject()':
moc_test_base.cpp:(.text+0x34): multiple definition of
`Form1::staticMetaObject()'
.obj/release-shared/moc_test.o:moc_test.cpp:(.text+0x34): first defined
here
.obj/release-shared/moc_test_base.o: In function `Form1::tr(char const*,
char const*)':
moc_test_base.cpp:(.text+0xa0): multiple definition of `Form1::tr(char
const*, char const*)'
.obj/release-shared/moc_test.o:moc_test.cpp:(.text+0xa0): first defined
here
.obj/release-shared/moc_test_base.o: In function `Form1::tr(char const*)':
moc_test_base.cpp:(.text+0xd4): multiple definition of `Form1::tr(char
const*)'
.obj/release-shared/moc_test.o:moc_test.cpp:(.text+0xd4): first defined
here
.obj/release-shared/moc_test_base.o: In function `Form1::initMetaObject()':
moc_test_base.cpp:(.text+0x10c): multiple definition of
`Form1::initMetaObject()'
.obj/release-shared/moc_test.o:moc_test.cpp:(.text+0x10c): first defined
here
.obj/release-shared/moc_test_base.o:(.bss+0x4): multiple definition of
`Form1::metaObj'
.obj/release-shared/moc_test.o:(.bss+0x4): first defined here
.obj/release-shared/moc_test_base.o:(.rodata+0x0): multiple definition of
`vtable for Form1'
.obj/release-shared/moc_test.o:(.rodata+0x0): first defined here
collect2: ld returned 1 exit status
make: ***
[/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qtopia/bin/test]
Fehler 1

Spice
Hi,
does nobody knows how to create an app using qt2 designer, uic, qmake? I
cannot compile my files, because of errors. I think my environment is
correctly setup, and i can build the examples correctly, but i am not able
to create/compile own project. I am not familiar with Qt... If somebody
knows how to create an app for qtopia 2.2.0 with qt2, i would be glad about
every posting. 
Thanks,have a nice sunday

eddylau
Hey Spice,
I have successfully developed some qt2 applications under qtopia2.2 using
FriendlyARM mini2440.
One thing You have to bear in mind is that developing qtopia application
is different from traditional desktop qt application.
I don't need to use uic manually to generate those .h and .cpp files.
when building the program, it will automatically do the uic thing behind
the scene.
May me you can uplaod your whole project here and let me see whether I
can compile it for you or not?

Good luck 

Eddy

Spice
Hey Eddy, thanks for your promt reply,
 
I have uploaded my whole files here
http://www.mikrocontroller.net/topic/171648

i´m struggeling since some days about this problem. I´m able to compile the
examples, but my own testapp won´t compile. These are my first steps in
programming linux and qtopia, therefore i would appreciate if u could help
me to run my own testapp or if u describe how you proceed. I´m generating
manually the sourcefiles with uic. Is it not correct? 
also i dont understand why in the hello-example a headerfile named
hello_base.h is included in one sourcefile and where to find the headerfile
and why they include this file. 
Maybe u can upload one of your working basic projects with one button, to
show how to create a basic project.  

Thank u very much for your support
Spice

eddylau
I just read you programs and know what's your problem.

In developing qtopia app, you don't need to use uic manualy

because the files testme.h and testme.cpp should be manually

written by you, not generate by uic.

When you build the program,uic will generate test1.h and test1.cpp

from your test1.ui behind the scene.

You then add #include "test1.h" in your testme.h so that you can

access the components designed in your form from designer.

The generate test1.h and test1.cpp is stored in a hidden folder(.ui)

where you can use #ls -a command to see it.

But you should not modify these self-generated files, instead you

should extend Form1 class from the testme.cpp file and do your

own stuff there.

I hope you understand what I mean.

Thanks

Eddy

Spice
hey eddy, 

thank u for your post.
i don´t understand all steps, but i´m goint to google and search for
detailed information. do u use an IDE? how u build your project in detail,
from your .ui file? if i use ./designer, i only get an .ui file, but how to
continue? Is there any option to use an IDE with the correct settings? I
only have the example hello for the mini2440 and no other references. Do u
have any Links where I can look around to get detailed information on how
to create a basic app for the mini2440? 
thx Spice

eddylau
It's quite sad to know that you don't understand what I mean!

I don't think you can get any detailed information about qtopia2.2 app
from google. You know, qtopia2.2 is only an obsoleted pda platform adopted
by FriendlyARM in there products.

I have posted some of my application demo video to youtube,but mostly in
chinese explanation.

here is a game of tic_tac_toe written by me:
http://www.youtube.com/watch?v=BboGRZ27wv4

I haven't use any IDE in developing all my qtopia app. Just use gedit to
edit the source code.

Anyway, good luck to you.

Eddy

Spice
Hey Eddy,

thank u very much. With your posts and lerning by doing, now i'm able to
compile my projects without a problem and up them to the mini2440... 
works fine, but where to get API-documentations? In the included doc-files?
How can i access the terminal to start a shell script, if i push a button?
I tried Qprocess and system("....") but no success. 

Thank u and greetz
Spice

eddylau
Hey Spice,

It's glad to know that you successfully compiled you projects.

You can find Qt API-documentations from
/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qt2/doc/html/index
.html.

I am not quite understand what do you mean by "access the terminal to start
a shell script".

In Qt, you can issue command to linux by using system("....") as you
mentioned.

Thanks

Eddy

kevin
Hi spice we would be very greatful to u if u can share with us how you
managed to compile your qt code for arm mini2440.Waiting for yur positive
reply
kevin