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
3 answers

Where is Qt::escape(const QString & plain) in Qt4.8.6?

I need the Qt::escape(const QString & plain), but it seems to be deprecated in my version of Qt 4. This is my version of Qt4, I am using update-to-date Debian sid distro. me@debian$ dpkg -l | grep qt4-default ii qt4-default…
sadhen
  • 462
  • 4
  • 14
0
votes
1 answer

How to get second value in QMap >

I have structure QMap > *map; Next I insert data: map = new QMap >; QMap *d = new QMap; d->insert("Name","Michal"); map->insert("QLineEdit",*d); if I…
MiMo
  • 124
  • 1
  • 2
  • 9
0
votes
1 answer

How to write a raw QByteArray or manipulate the QByteArray

I defined a QIODevice (especially a QTcpSocket) and would like to write a string as raw format. I describe my wishes with the following example: char* string= "Hello World"; QByteArray bArray; QDataStream stream(&bArray,…
3ef9g
  • 781
  • 2
  • 9
  • 19
0
votes
1 answer

How convert QString to char correctly when Chinese characters are involved

A Qt object bases on Qt4 and runs on CentOS 7. I get a QString file directory from getExistingDirectory. File name contains Chinese characters. Then I use toLocal8Bit to convert it to char, and the char variable occurs messy code. I tried QTextCodec…
cyberpunker
  • 49
  • 1
  • 1
  • 7
0
votes
1 answer

Reusing Qt's QString COW / ref counting in a string registry

I work on a project that is supposed to have large object count (in the range of millions), and even though object names are not mandatory, they are supported for the user convenience. It would be quite a big overhead to have an empty string member…
user3735658
0
votes
2 answers

QString() vs sprintf()

I have some code where in, there is a TCP connection between the client and the server. I need to send some xml data to the server and receive a response from it. I am trying to do it like this: char request[MAX]; sprintf(request,…
Shwetha
  • 150
  • 7
0
votes
1 answer

Forward declaration of array of QStrings leads to segmentation fault

In this code I have two forward declarations, a bool array and a QString array in namesace NLog. bool works. QString produces a segmentation fault. Header: class Log : public QObject { explicit Log(); public: enum Facility { …
user2136963
  • 2,526
  • 3
  • 22
  • 41
0
votes
0 answers

QString split() function with QRegExp strange behaviour

I have some text like this: "1.801908\t20.439980\t\r\n25.822865\t20.439305\t\r\n26.113739\t4.069647\t\r\n1.800252\t4.301690\t\r\n" I want to split this text by lines and then by tabs. I am using QString split() function and QRegExp to do that in…
TinF
  • 89
  • 7
0
votes
1 answer

Qt/C++ - How to remove a whole line from a string?

I am using QString::remove(QString) to remove a specific line from a string, but there's a small problem which is the removed string isn't really removed, it is replaced with an empty string instead. I want to remove the whole line…
Alaa Salah
  • 885
  • 1
  • 13
  • 23
0
votes
1 answer

TypeError while using QTextEdit methods

I have built a text editor using PyQt and I'm trying to display a string to it I tried to use QTextEdit.append(), QTextEdit.setText() but I'm getting TypeError in each case. I'm doing: qstring_result =…
tryPy
  • 71
  • 1
  • 11
0
votes
3 answers

QByteArray to QString to std::stringstream doesn't work

anyone know why QString Lulu ( data ); //data is a QByteArry ( from a QNetworkrequest ) std::stringstream streamedJson ; // QString Lulu ( data.data() ); qDebug()<< "Lulu:" << Lulu; // here it views the right string streamedJson <<…
thelittlePanda
  • 101
  • 2
  • 10
0
votes
1 answer

Qt Split QString

Assume I have a QString like this: [General] APPLICATION_NAME=skype Pickup_key=222 Hangup_shift=55 Hangup_key=223 Reject_key=556 Pickup_ctrl=1 How would I grab something like ONLY the 222 in Pickup_key and store it into an int? The integer values…
user352258
  • 45
  • 3
  • 10
0
votes
1 answer

Managing a QStringList-based model from the QML side

I can expose a QStringList-based model from C++ side to QML as explained here How can I modify it the QStringList-based model from the QML side (insert new items, delete them)? Are some functions of QStringListModel or QStringList available to be…
marmistrz
  • 5,974
  • 10
  • 42
  • 94
0
votes
1 answer

QT: Error trying to store QString in std::pair

I'm trying to store a QString and a bool in a vector as a pair. I keep getting the error no matching function for call to 'make_pair(bool, QString&)' messages.push_back(make_pair(true, message)); when I run following function: void…
isADon
  • 3,433
  • 11
  • 35
  • 49
0
votes
1 answer

Qt QString Q_PROPERTY causing SIGSEGV

I ran into this problem the other day - caught me by surprise and has halted my testing. I'm developing a feature outside of my normal application and I ran into an issue with a Q_PROPERTY that I can't seem to figure out. I've simplified the…
Boreet
  • 53
  • 1
  • 4