hi experts
i'm working on Mac OS 10.4 and using qt4.2 for developing application
can u please tell me how can i change the text of line edit or text edit in after selecting a new language in my code which r included in my application folder
u see my .pro file and .qrc file
.qrc file is:
<RCC version="1.0">
<qresource>
<file>translations/langChange_ar.qm</file>
<file>translations/langChange_cs.qm</file>
<file>translations/langChange_de.qm</file>
<file>translations/langChange_el.qm</file>
</qresource>
</RCC>
.pro file is
TEMPLATE = app
TARGET =
DEPENDPATH += . translations
INCLUDEPATH += .
# Input
HEADERS += langChange.h
FORMS += langChange.ui
SOURCES += langChange.cpp main.cpp
RESOURCES += langchange.qrc
TRANSLATIONS += translations/langChange_ar.ts \
translations/langChange_cs.ts \
translations/langChange_de.ts \
translations/langChange_el.ts
now can u please do tell me where is the problem going on
code is:
langChange::langChange(QWidget *parent): QDialog(parent)
{
setupUi(this);
qmFiles = namesQmFiles();
languageChanged();
connect(comboBox,SIGNAL(activated(QString )), this,SLOT(changed(QString )));
}
void langChange :: languageChanged()
{
for (int i = 0; i < qmFiles.size(); i++)
{
comboBox->insertItem(0,languageName(qmFiles[i]),QVariant());
}
}
void langChange :: changed(QString str)
{
str=textEdit->toPlainText ();
//QMessageBox::information(0,"!!",languageName(str)) ;
//WHAT TO DO
}
/*WHEN I USE QMESSAGEBOX TO GET TRANSLATED STRING IT RETURNS NOTHING
QString langChange::languageName(const QString &qmFile)
{
QTranslator translator;
translator.load(qmFile);
//qApp->installTranslator(&translator);
return translator.translate("MainWindow", "English");
}
QStringList langChange::namesQmFiles()
{
QDir dir("/test/translations");
QString strFileName = "";
QStringList fileNames = dir.entryList(QStringList("*.qm"), QDir::Files,QDir::Name);
QMutableStringListIterator i(fileNames);
while (i.hasNext())
{
i.next();
i.setValue(dir.filePath(i.value()));
}
return fileNames;
}
PLEASE DO TELL ME WHERE THE PROBLEM IS OCCURING TO GET TRANSLATED STRING IN ANY OTHER LANGUAGE AS 4 .qm FILES ARE LOADED IN COMBOBOX
WHAT TO DO WITH CODE OR WHAT WILL BE THE SIGNAL SLOT ..IS THERE ANY PROBLEM IN SIGNAL SLOT OR WHAT TYPE...I AM NOT GETTING WHY STRING NOT TRANSLATED IF LANGUAGE NAMES ARE LOADED IN COMBOBOX IN DIFFRENT LANGUAGES
THANKS IN ADVANCE
Bookmarks