9 24
时间:2010-09-24 来源:harryxiyou
Today, I just know some skills about qt so i get it to my blog. When you want to
change "char *" to "QString" and change "QString" to "char *", you can get following programs.
#include <QtGui/QApplication>
#include <QTextCodec>
#include <QDebug>
#include <QString>
#include <stdio.h>
#include <QChar>
#include <QDebug>
#include <QByteArray>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextCodec::setCodecForTr( QTextCodec::codecForLocale() );
//char *p;
/* QString str = "hello world";
QByteArray ba = str.toLatin1();
char *p = ba.data();
*/
char c_str2[] = "hello world!";
printf( "%s\n", c_str2 );
QString string = QString(QLatin1String(c_str2));
qDebug()<<string;
return a.exec();
}
change "char *" to "QString" and change "QString" to "char *", you can get following programs.
#include <QtGui/QApplication>
#include <QTextCodec>
#include <QDebug>
#include <QString>
#include <stdio.h>
#include <QChar>
#include <QDebug>
#include <QByteArray>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextCodec::setCodecForTr( QTextCodec::codecForLocale() );
//char *p;
/* QString str = "hello world";
QByteArray ba = str.toLatin1();
char *p = ba.data();
*/
char c_str2[] = "hello world!";
printf( "%s\n", c_str2 );
QString string = QString(QLatin1String(c_str2));
qDebug()<<string;
return a.exec();
}
相关阅读 更多 +