Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

如何将TBuf转换为QString

From 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 01:18.
66 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×