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. Thanks for all your past and future contributions.

How to convert TBuf to QString

From Wiki
Jump to: navigation, search

This code snippet demonstrates how to convert a Symbian TBuf descriptor to a Qt QString. For information about converting other descriptor types see Using Qt and Symbian C++ Together#Converting a Descriptor to a QString.

Article Metadata
Tested with
SDK: Qt SDK 1.1.3
Devices(s): Emulator
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
Platform Security
Signing Required: Self-Signed
Capabilities: None
Keywords: QString,TBuf
Created: kamaljaiswal (17 Jan 2009)
Last edited: hamishwillee (30 May 2013)

TBuf to QString

TBuf<10> buf(KMsg);
QString qString((QChar*)buf.Ptr(),buf.Length());

QString to TBuf

QString text = "Some text";
TPtrC16 textPtr(reinterpret_cast<const TUint16*>(text.utf16()));


QString text = "Some text";
TBuf<KBufLength> buffer(text.utf16());
This page was last modified on 30 May 2013, at 06:34.
99 page views in the last 30 days.