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

Qt: detecting a non-translated QString (not from a tr())

What chances do I got in finding all QStrings that do miss a tr()-translate call in a very old and very huge Application? I was thinking something like... make a special .ts file for debugging use only and add a static prefix to all translations.…
Hhut
  • 1,128
  • 1
  • 12
  • 24
0
votes
1 answer

Replace spaces in QString with backslash spaces

I need to replace spaces in a QString with backslash spaces. I have: QString myPath = /home/matt/my file.txt I need: QString myPath = /home/matt/my\ file.txt I tried using myPath.replace(" ", "\ "); but unfortunately the compiler interrupts this…
M. P.
  • 91
  • 2
  • 10
0
votes
2 answers

How do I print QStringListModel content?

I need to print the content of a QStringListModel to a printer, in 'void MainWindow::on_pbImprime_clicked()' It's printing any Qstring with no problems, but I don't know how to put the data of QStringListModel to my QString text, anyone have an…
0
votes
1 answer

QString returning different sting on same compilation (but different systems)

I need to install a lib that uses Qt on an old machine that runs openSuse 11 i586. Actually, my build machine runs Ubuntu and we have our own Qt compilation - in order to use static feature. Apparently, both machines (build and target) has…
Raiden
  • 1
0
votes
1 answer

PyQt : make a Dict from Text Edit, or transform a PyQt4.QtCore.QStringList in common Dict

I get from QtextEdit some "code", I mean something like : 1, A, B, D, 1 1, B, B, D, 2 2, A, C, G, 1 and I would like to get a dictionary like : table={'1':{'A':['B', 'D', '1'], 'B':[B, D, 2]}, '2':{A:['C', 'G', '1']} And then access it:…
Dadep
  • 2,796
  • 5
  • 27
  • 40
0
votes
3 answers

Building QString out string

With the following piece of code: QString msg; msg = "Datalogging Item" + ',' + QString::number(item) + ',' + "Slave Index" + ',' + QString::number(slaveIndex) + ',' + "Slave Name" …
Sebastien
  • 23
  • 2
0
votes
1 answer

C++ Qt QString replace double backslash with one

I have a QString with following content: "MXTP24\\x00\\x00\\xF4\\xF9\\x80\r\n" I want it to become: "MXTP24\x00\x00\xF4\xF9\x80\r\n" I need to replace the "\x" to "\x" so that I can start parsing the values. But the following code, which I think…
Dumbo
  • 13,555
  • 54
  • 184
  • 288
0
votes
3 answers

Watch a QStringList for new items

I am working on a data logger in QT framework. I Intend to save log strings to files and print to the console in a separate watcher thread. In that separate thread I need to watch my QStringList for new items added. If there are new items I deque…
Łukasz Przeniosło
  • 2,725
  • 5
  • 38
  • 74
0
votes
1 answer

Comparing international strings

What I am trying to do is comparin 2 QStrings that have special characters (French) first I recieved from server as json data saved in txtInfo txtInfo = "Présenter"; When I am having condition like this it's not gonna work(its not gonna set…
Dušan Tichý
  • 498
  • 1
  • 7
  • 21
0
votes
1 answer

QString::fromUtf8(str) and \u encoded character sequences

I was using string literals with \u encoded sequences, for passing them to QString::fromUtf8, like in QString::fromUtf8("Precio (\u20AC/k)");, with success, but, struggling my mind a bit, and reading cppreference and other sources, I have not clear…
ABu
  • 10,423
  • 6
  • 52
  • 103
0
votes
1 answer

Pass empty string to constructor

note: I am still new to c++, and while this may be a simple issue, yet I am unable to find a solution. Purpose: I would like to pass an empty string (as one would in java/C#) to my constructor. I receive an error: error: no matching function for…
CybeX
  • 2,060
  • 3
  • 48
  • 115
0
votes
0 answers

Segfault passing QString to function

I want to pass G-CODEs to a 3D printer from my Qt app. I have a function that takes a QString and passes it to an external program as an argument: void MainWindow::gcodeRelay( const QString &gcode ) { QObject *parent; relayProcess= new…
0
votes
1 answer

Get the previous element of a QStringList

I'm currently working on a small program where I will count the amount of times a certain word is mentioned in a text. But I only want to count for the word when the previous element is a 10 digit number. So what I'm trying is do is that I will…
Mrchacha
  • 197
  • 1
  • 17
0
votes
1 answer

Create QString array of two dimensions with QVector with Qt

I want to to put in array some QString words but I don't know how can I do. I have try with Vector like this : int i = 10; int j = 10; QVector < QVector < QString> > tableau; QString word = "Word"; tableau[i][j] = word; But that don't work. This…
Mathis Delaunay
  • 172
  • 1
  • 16
0
votes
1 answer

Qt QString lastIndexOf not working

I'm using Qt5.6, I'm trying to use the QString function lastIndexOf. The subject data contains something like: 156 + (28 * 4) + (14 * 9 * 2) Using indexOf: int intOpB = strLocalCopy.indexOf(ucOpenBracket); strLocalCopy contains the…
SPlatten
  • 5,334
  • 11
  • 57
  • 128