×
Namespaces

Variants
Actions

如何将TBuf转换为QString

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

兼容于
平台:
Symbian

文章
翻译:
hoolee
最后由 hamishwillee 在 11 Oct 2012 编辑


概述

下列代码演示了如何将TBuf(Symbian描述符)转换为QString(Symbian上的Qt平台)

源文件

#include <QtGui>
#include <QApplication>
#include <qstring.h>
#include <QLabel>
#include <QVBoxLayout>
#include <QWidget>
 
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win = new QWidget;
QLabel *label = new QLabel();
QVBoxLayout *layout = new QVBoxLayout;
 
_LIT(KMsg,"Hello");
TBuf<10> buf(KMsg);
QString qString((QChar*)buf.Ptr(),buf.Length());
 
label->setText(qString);
layout->addWidget(label);
 
win->setLayout(layout);
win->show();
 
return a.exec();
}

截图

Buffff.PNG

This page was last modified on 11 October 2012, at 04:18.
60 page views in the last 30 days.