What is the difference between Qstring and Qstringliteral?

Asked

Viewed 307 times

2

What is the difference between the two? What is the best to use?

  • If possible pass me tutorials/Qt information sites in Portuguese please... For me to delve into this framework

1 answer

1


QString is a type representing text in Qt. It is the equivalent of the type string of C++, but they are not compatible, they are stored differently. When using Qt it is usually more advantageous to apply this type to avoid unnecessary conversions in various situations.

QString variavel("hello world");

The QStringLiteral is just a macro created from version 5 that creates a literal string compatible with type QString. Before what was done is to create a literal string and then a conversion was done when it was passed to a Qt method that expects a Qstring. This macro avoids this conversion.

if (node.hasAttribute(QStringLiteral("http-contents-length")))

Material in Portuguese from Qt is very complicated, gives a look in that, but I don’t know if it’s good.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.