Skip to content
nucularmoo edited this page Mar 16, 2018 · 35 revisions

String handling and value types

Explanation of the contents of a topic page @ Week 1 Topic 1

Back to Week 1

Objective: Basic string manipulation (min: QString + QChar + QCodec, creating, concatenation + light-weight use with QLatin1String (or QStringView this one may be omitted)

Comment: There is no String type in Qt, so should be written on lower-case (E: I'll leave this here for reference. Actually I'll just leave all the comments here for reference, comment on them myself so the dialogue stays somewhere. I didn't do that for 1.00 but it will probably be a better idea to just leave all the comments on the topic content pages for future references.)

Comment: This is a huge topic and I'd try to avoid losing attendees' interest at the beginning. The minimum: QString + QChar + QCodec, creating, concatenation + light-weight use with QLatin1String or QStringView (the latter can be omitted). String literals could be already another topic. And QByteArray is relevant in cases, where coding is not needed. I'm afraid this is too much for one section, isn't it.

E: Ill bump String Literals and QStringView into the expert section and include them if it seems feasible after everything else has been seen to.

Comment: The important message is that we do have literals and it does make sense to use mutable strings in general, if literals are ok. Like file names.

Beginner

Intermediate

  • What is QString?
  • QString vs QByteArray?
  • How does std::string/c string compare to QString?
  • How do you compare and manipulate strings efficiently (QLatin1String, QStringRef, ((QStringView)))?
  • What are value types in Qt?

Expert

  • What is QStringLiteral?
  • What is QStringView?

Course material content

As our next topic we're going to take a look at some basic string manipulation, interesting string facts and some value types. We'll also take a brief look at how to compare and manipulate strings efficiently.
To start, there is no String type in Qt, so in the case of writing, it should be written on lower-case. If you should walk away from this topic with something in mind, it is that Qt does have literals and that it does make sense to use mutable strings in situations where literals are ok, such as file names.

We will start with string manipulation, after which we will take a comparative look at QString and QByteArray. After that, we will take a look at how std::string and c string compares to QString, followed by a brief discussion about how to compare and manipulate strings efficiently. Lastly, we will discuss value types in Qt.

String manipulation (QString, QChar, QCodec)

http://doc.qt.io/qt-5/qstring.html
http://doc.qt.io/qt-5/qchar.html
http://doc.qt.io/qt-5/qtextcodec.html

Basic string manipulation (min: QString + QChar + QCodec, creating, concatenation + light-weight use with QLatin1String

QString vs QByteArray

http://doc.qt.io/qt-5/qbytearray.html

std::string/c string vs QString

http://2016-aalto-c.mooc.fi/fi/Module_2/index.html#04_strings

Comparing and manipulating strings efficiently

http://doc.qt.io/qt-5/qlatin1string.html
http://doc.qt.io/qt-5/qstringref.html
https://doc.qt.io/qt-5/qstringview.html

Value types in Qt

http://doc.qt.io/qt-5/custom-types.html


Exhaustive reference material mentioned in this topic

Further reading topics/links:

Clone this wiki locally