| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 2 | |
#include <QtGui/QApplication>
Dear all, I wrote the following code, but I don't know what's wrong with it.
#include <QtGui/QWidget>
#include <QtGui/QLabel>
#include <QtCode/QTextCodec>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextCodec:setCodecForTr(QTextCodec::codecForName("gb18030"));
QWidget* pWidget = new QWidget;
QLabel label(pWidget);
label.setText(QObject::tr("Some Chinese Characters"));
pWidget->show();
return app.exec();
}
The wrong information is:
src/main.cpp: In function âint main(int, char**)â:
src/main.cpp:30: error: âsetCodecForTrâ was not declared in this scope
src/main.cpp:30: warning: label âQTextCodecâ defined but not used
make: *** [main.o] Error 1
kermit@linux-ezwe:~/QtProject/hello> label âQTextCodecâ defined but not used
bash: label: command not found
kermit@linux-ezwe:~/QtProject/hello>
======================================
English is not my first language, so need setCodecForTr().
Would you like to tell me what's wrong with it?
Thanks.
Kermit
--
[ signature omitted ]
I believe you forgot colon at QTextCodec:setCodecForTr(...) should be
QTextCodec::setCodecForTr(...)
On 12-Mar-08, at 7:50 AM, Kermit Mei wrote:
> #include <QtGui/QApplication>
> Dear all, I wrote the following code, but I don't know what's wrong
> with it.
>
> #include <QtGui/QWidget>
> #include <QtGui/QLabel>
> #include <QtCode/QTextCodec>
>
> int main(int argc, char *argv[])
> {
> QApplication app(argc, argv);
> QTextCodec:setCodecForTr(QTextCodec::codecForName("gb18030"));
> QWidget* pWidget = new QWidget;
> QLabel label(pWidget);
> label.setText(QObject::tr("Some Chinese Characters"));
> pWidget->show();
> return app.exec();
> }
>
> The wrong information is:
> src/main.cpp: In function ‘int main(int, char**)’:
> src/main.cpp:30: error: ‘setCodecForTr’ was not declared in this scope
> src/main.cpp:30: warning: label ‘QTextCodec’ defined but not used
> make: *** [main.o] Error 1
> kermit@linux-ezwe:~/QtProject/hello> label ‘QTextCodec’ defined but
> not used
> bash: label: command not found
> kermit@linux-ezwe:~/QtProject/hello>
> ======================================
> English is not my first language, so need setCodecForTr().
> Would you like to tell me what's wrong with it?
> Thanks.
>
> Kermit
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]
Simon Berube wrote: > I believe you forgot colon at QTextCodec:setCodecForTr(...) should be > QTextCodec::setCodecForTr(...) > Hmm,thank you all. And the other error is that I should #include <QTextCodec>. But, this class is unuseful for me, which I want to output is also random code. -- [ signature omitted ]
On Wednesday 12 March 2008 12:50:54 Kermit Mei wrote:
> Â Â Â QTextCodec:setCodecForTr(QTextCodec::codecForName("gb18030"));
Missing one : between QTextCodec and setCodecForTr.
--
[ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.
Hi,
Should it not read:
QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
--
[ signature omitted ]