Namespaces
Variants
Actions
Revision as of 10:17, 3 September 2009 by croozeus (Talk | contribs)

How to convert TBuf to QString

Jump to: navigation, search


Article Metadata

Tested with
Devices(s): Emulator

Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition

Article
Keywords: QString,TBuf
Created: (17 Jan 2009)
Last edited: croozeus (03 Sep 2009)


Overview

This code snippet demonstrates how to convert TBuf (Symbian Descriptor) to QString (Qt for S60) .

Preconditions


Source File

#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();
}

Screenshot

Buffff.PNG

170 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved