/*Sending the text which needs to be translated*/
void myQtApp::translate()
{
from = langs->at(langfrom->currentIndex() );
to = langs->at( langto->currentIndex() );
text =text_from->toPlainText();
ba.append( text.toUtf8() );
QString url
=QString("http://translate.google.com/translate_a/t?Client=t&sl=" + from
+ "&tl=" +to
);
http->setHost("www.google.com");
http->post(url,ba);
}
/*The translated text is set in the 'to' text edit box.*/
void myQtApp::done()
{
QMessageBox::information(NULL,
"reached",
"entered done loop");
ba1=http->readAll();
transtext=text1.fromUtf8(ba1);
text_to->setText(transtext);
}
/*When the data is sent to google,the requestStarted(int) signal is generated which calls this slot*/
void myQtApp::started()
{
int id1=http->currentId();
}
/*Sending the text which needs to be translated*/
void myQtApp::translate()
{
QString from, to, text;
from = langs->at(langfrom->currentIndex() );
to = langs->at( langto->currentIndex() );
text =text_from->toPlainText();
QByteArray ba("text=");
ba.append( text.toUtf8() );
QMessageBox::information(NULL,"outgoing data",QString(ba));
QString url=QString("http://translate.google.com/translate_a/t?Client=t&sl=" + from + "&tl=" +to);
QMessageBox::information(NULL,"url",url);
http->setHost("www.google.com");
http->post(url,ba);
}
/*The translated text is set in the 'to' text edit box.*/
void myQtApp::done()
{
QMessageBox::information(NULL,"reached","entered done loop");
QString transtext;
QByteArray ba1;
ba1=http->readAll();
QString text1;
transtext=text1.fromUtf8(ba1);
QMessageBox::information(NULL,"received",transtext);
text_to->setText(transtext);
}
/*When the data is sent to google,the requestStarted(int) signal is generated which calls this slot*/
void myQtApp::started()
{
int id1=http->currentId();
QMessageBox::information(NULL,"process no.",QString(id1));
}
To copy to clipboard, switch view to plain text mode
Bookmarks