What is the difference between QString and QStringLiteral?

2

What's the difference between the two? Which one is best to use?

    
asked by anonymous 02.12.2015 / 21:11

1 answer

1

QString is a type represents text in Qt. It is the equivalent of 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 that, it was done to create a literal string standard and then a conversion would be done when passing it to a Qt method that expects a Qstring . This macro avoids this conversion.

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

Qt's Portuguese material is quite complicated. Take a look on , but I do not know if it's good.

    
02.12.2015 / 21:17