Questions tagged [qstring]

A QString is a class in Qt library which implements character strings.

QString holds a unicode string inside, and provides a set of useful functions to manipulate the data, including easy concatenation, trimming, search and replace, and conversion functions.

QString can also be converted to std::string and vice-versa with toStdString() and fromStdString() respectfully:

QString str = QString::fromStdString( std::string("Hello, World!") );

std::string str = QString("Hello world!").toStdString();

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

791 questions
0
votes
1 answer

Creating a QList of QMaps out of a QString

I'm having an struggle with a de-serializing operation, look I have a QString like this: [{"value": "", "type": "tag", "name": "Output Tag", "param": "outputtag"}, {"value": "black", "type": "colour", "name": "Init Colour", "param": "initcolour"},…
0
votes
1 answer

Reading percentage encoded url with umlauts with Qt

I am trying to read percentage encoded urls with umlauts, such as äüö,..., with Qt: QString str = "Nu%CC%88rnberg" qDebug() << QUrl::fromPercentEncoding(str.toUtf8()); But the output is Nu¨rnberg instead of Nürnberg. How can I correctly decode urls…
Hyndrix
  • 4,282
  • 7
  • 41
  • 82
0
votes
0 answers

How to make QString with inheritance Threadsafe

My aim is to make a QString threadsafe (by default, a QString is reentrant). I want to use a map with multiple QStrings and access them with multiple threads. Most of the time, the threads will read but sometimes 1+ of them will write data to these…
Cherubim
  • 13
  • 4
0
votes
2 answers

convert QString to Gbytes

want to convert a QString to GBytes (glib) I tried the following by converting the QString to GByteArray and than freeing it to GBytes extern "C" { #include }; #include #include int main(int argc, char…
Gtk Fan
  • 45
  • 6
0
votes
1 answer

QString arg() issue when arg contains a % character... how to prevent recursive replacement?

I have an issue which somehow in years of using Qt has not appeared until now. QString message = "working"; QString a = QString("here is a %1 message. %2!").arg(message).arg("yay"); printf("%s\n",qPrintable(a)); Obviously works fine. But this will…
Eyelash
  • 1,760
  • 2
  • 12
  • 18
0
votes
0 answers

Using boost-spirit to parse string to struct of QStrings

Today, I tried to write a very simple parser using boost-spirit. Now, I stumbled over an obstacles, that I really don't know how to resolve. Basically, I wanted the semantic action to return a QString instead of the Stl std::string. And I also…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
0
votes
0 answers

converting from QString to wstring adding extra escape sequence

I have a QString like QString qReplaceByText("**\\g**"); If I try to convert it to a wstring its replacing \ with \\ std::wstring wReplaceByText = qReplaceByText.toStdWString(); qReplaceByText becomes **\\\\g** How can I avoid this…
sameer karjatkar
  • 2,017
  • 4
  • 23
  • 43
0
votes
1 answer

How to search substring in QLatin1String?

What is the reason that QLatin1String class has not any operations for searching substring in it, such as indexOf, find or contains? Only startsWith and endsWith I was found, but they can't search in the middle of the string
Denis
  • 2,786
  • 1
  • 14
  • 29
0
votes
1 answer

Qt: Separate input and display on new lines

I am trying to get a user to type in an address that is comma delimited. The idea is that the program will display the address in a correct format on new lines. I am new to using Qt Creator. I am trying to convert the input to a list and then…
N101Seggwaye
  • 75
  • 2
  • 16
0
votes
1 answer

How i can split a string in more substrings in QT?

I'm new to qt I want to know how I can split a string into substrings with one or more operation. This is an example QString FileName = "ABCD_1234_5678.exe"; I want this output or substrings: "ABCD" "1234" "5678"` The QString in my application…
pablodepas87
  • 197
  • 1
  • 16
0
votes
1 answer

Reading sqlite raw data into QByteArray

I have a qsqlite which has a column contains raw data. The codes QByteArray data= query.value("data").toString().toLatin1(); or QByteArray data= query.value("data").toByteArray(); give the exact same results which are correct except for some…
mehmetfa
  • 199
  • 3
  • 15
0
votes
4 answers

Qt - How to use SQL SELECT COUNT with parameters?

I'm writing a program in QT and have a problem with writing an SQL query Select. I have a simple table which contains columns like: ID, name_or_nickname, surname, occupation. I have 3 variables I want to use in the query: QString name =…
0
votes
2 answers

How to convert unicode QString to an std::string?

I need convert a QString to an std::string. However, if this string contains unicode symbols, I get ????. How can I convert the string with the proper encoding? Thank you.
0xAX
  • 20,957
  • 26
  • 117
  • 206
0
votes
2 answers

How do write template function that can get a substring of a QString or a std::string?

I'd like to write a template function that can handle both QString and std::string in order to reduce copied code. Unfortunately, QString does not implement the substr member function. QString::mid(int, int) seems to be the Qt analogue. What is…
Ben Jones
  • 652
  • 6
  • 21
0
votes
1 answer

In Qt, how do I convert the Unicode codepoint U+1F64B to a QString holding its equivalent character ""?

Background: I am making a hash that will allow you to lookup the description you see below by feeding it a QString containing its character. I got a full list of the relevant data, looking something like this: QHash
Anon
  • 2,267
  • 3
  • 34
  • 51