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.

Converting between Qt and Symbian Directory Separators

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: hamishwillee (05 Apr 2011)
Last edited: hamishwillee (30 May 2013)

This article shows how to convert between directory separators used in Qt and those used by Symbian. Note that you only need to do this if you're directly mixing Qt and Symbian C++ code.

Contents

Overview

Qt uses a forward slash directory separator ( "/") while Symbian natively uses a backslash separator ("\"). The following sections show how to convert between the sections. The example assumes you're obtaining a private directory.

Source code

Convert using QString::replace() method

/* this code will convert path from C:/Private/ed8788dc to C:\Private\ed8788dc */
QString privatePathQt(QApplication::applicationDirPath());
QString privatePathSymbian(privatePathQt.replace("/","\\"));


Convert using QDir::toNativeSeparators() method

/* this code will convert path from C:/Private/ed8788dc to C:\Private\ed8788dc */
QString privatePathQt(QApplication::applicationDirPath() );
QString privatePathSymbian(QDir::toNativeSeparators(privatePathQt));

Converting path from Symbian format to Qt format

Similarly we can convert back it to Qt format as follows.

Source code

Convert using QString::replace() method

/* this code will convert path from C:\Private\ed8788dc to C:/Private/ed8788dc */
QString privatePathSymbian("C:\Private\ed8788dc");
QString privatePathQt(privatePathSymbian.replace("\\","/"));

Convert using QDir::fromNativeSeparators () method

/* this code will convert path from C:\Private\ed8788dc to C:/Private/ed8788dc */
QString privatePathSymbian("C:\Private\ed8788dc");
QString privatePathQt(QDir::fromNativeSeparators(privatePathSymbian));
This page was last modified on 30 May 2013, at 06:33.
42 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.

×