×
Namespaces

Variants
Actions

Right way to pass QString to methods

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Compatibility
Platform(s): all
Symbian
Article
Keywords: Qt, QString
Created: gnuton (20 Jun 2010)
Last edited: hamishwillee (11 Oct 2012)

A common programming mistake is passing QString as value to methods.

void method(const QString str);

This is allowed but it is not so efficient even if QString is implicitly shared .

A more efficient way is passing the const reference instead of the value.

void method(const QString& str);

This is valid also for other objects.

This page was last modified on 11 October 2012, at 04:18.
33 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.

×