Seite 1 von 1

Problem mit QTranslator (QT3.x Linux)

Verfasst: 12. Juli 2006 12:07
von needle
Hi,

ich versuche nen QTranslator zu nutzen, aber wenn ich mein Beispiel compiliere , dann fängt der Linker an zu meckern:
# make
/usr/local/qt/bin/uic fenster.ui -o .ui/fenster.h
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/local/qt/mkspecs/default -I. -I/usr/local/qt/include -I.ui/ -I. -I.moc/ -o .obj/main.o main.cpp
/usr/local/qt/bin/uic fenster.ui -i fenster.h -o .ui/fenster.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/local/qt/mkspecs/default -I. -I/usr/local/qt/include -I.ui/ -I. -I.moc/ -o .obj/fenster.o .ui/fenster.cpp
/usr/local/qt/bin/moc .ui/fenster.h -o .moc/moc_fenster.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/local/qt/mkspecs/default -I. -I/usr/local/qt/include -I.ui/ -I. -I.moc/ -o .obj/moc_fenster.o .moc/moc_fenster.cpp
g++ -Wl,-rpath,/usr/local/qt/lib -o language .obj/main.o .obj/fenster.o .obj/moc_fenster.o -L/usr/local/qt/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11-lm
.obj/fenster.o: In function `Fenster::init()':
fenster.cpp:(.text+0xfc): undefined reference to `myTrans'
fenster.cpp:(.text+0x1ae): undefined reference to `a'
fenster.cpp:(.text+0x1b3): undefined reference to `myTrans'
collect2: ld returned 1 exit status
make: *** [language] Fehler 1
Mein TestProjekt besteht lediglich aus main.cpp und einem Widget mit ui.h (im Designer erstellt)

main.cpp:

Code: Alles auswählen

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

int main( int argc, char ** argv )
{
	QApplication a( argc, argv );
	 
	QTranslator myTrans( 0 );
	myTrans.load( QString( "language" ) +"DEU", "." );
	a.installTranslator( &myTrans );
	
	Fenster w;
	w.show();
	a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
	return a.exec();
}
Das dazugehoerige Widget (Fenster) besteht aus einem QWidget welches ein QTextEdit enthält zum Anzeigen von dem übersetzten Text.

hier die fenster.ui.h:

Code: Alles auswählen

/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/

#include <qapplication.h>
#include <qtranslator.h>

extern QApplication a;
extern QTranslator myTrans;

void Fenster::init()
{
	bool TransLoad;
	textEdit->setText(tr( "falsches Passwort" ));
	
	TransLoad=myTrans.load( QString( "language" ) +"ENU", "." );
	if ( TransLoad==true )
	{
		textEdit->append("load of translator ok...");
		a.installTranslator( &myTrans );
		textEdit->append(tr( "falsches Passwort" ));
	}
	else
	{
		textEdit->append("load of translator not ok...");
	}
	
	
	return;
}
kann mir einer vielleicht sagen warum das so nicht geht?

Gruss,

needle