×
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.
40 page views in the last 30 days.
×