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

QString max split (amount of chunks?)

I am new to C++ and I am trying to use the Qt framework to create an app, however, I need to parse a big text file, struggling with the split() option. I am trying to split each line into 6 pieces, each string is not the same length, so not sure if…
0
votes
1 answer

Get ASCII value from QString and replace it with other ASCII

I need to get ASCII value from each QString's elements, then replace it with others ASCII. I have these QString: QString s = ui->lineEdit_3->text(); and QString k = ui->lineEdit_2->text();, then i converted s to Latin1 s.at(i).toLatin1(); but when…
GabryLinux
  • 155
  • 3
  • 8
0
votes
2 answers

Change the ith element of a QStringList

I am searching solution for half hour and no progress. Consider the list QStringList foo = {}; for (int i=1; i<8; i++){ foo << "0"; } If some check box was clicked, I'd like to change the value of the list to "1". So, for example, how to…
Sigur
  • 355
  • 8
  • 19
0
votes
0 answers

Qt QString quick processing problems

I am trying to use QString functions to process frames received via serial in quite fast succession. I am running into problems where the functions such as mid() seem to stop working when called too quickly in rapid succession. I wrote a small test…
englemon
  • 41
  • 2
0
votes
1 answer

Preserve QbyteArray to Qstring

I want to display the value of QbyteArray like how qDebug() displays it. qDebug()< "\x8E\xA9\xF3\xA5" how do you grab this QbyteArray into a QString, when i do the convertion found online it gives me "????" as an…
Jake quin
  • 738
  • 1
  • 9
  • 25
0
votes
2 answers

How to get the src of an image tag using QRegExp and QString

So I have got a string in my app which contains an html img tag Now I want to extract the image tag and its src attribute in two different strings. So what I tried to do is this: QRegExp…
reckless
  • 741
  • 12
  • 53
0
votes
1 answer

In QT i have function xyz() and i need to return QImage and QString both?

In the function xyz(), I am calculating the string value and number of image and I need to return all the value like string and image. So, What I need to take the return type so they will take all value? MainWindow::xyz(QString…
Amar Yadav
  • 29
  • 9
0
votes
0 answers

Add multiLine QString in single row of QTableView

QAbstractTableModel is used with QTableView I want to show three lines text in single cell of QTableView The cell may only occupy three lines, Consider QStrings as: QString A = "No failed tests found, a possible compilation error. Please…
karan chavan
  • 215
  • 2
  • 12
0
votes
3 answers

How to stop backslashes from cancelling in conversion from QString to char array?

I am writing a QT widgets application that includes serial communication with an Arduino. I found a good header and cpp file on GitHub that makes communicating with an Arduino MUCH easier than it would be with QSerialPort. However one difficulty…
user9420815
0
votes
0 answers

Text from qstring has &

I have a button with value of "a" set from the qt designer, i can also see that the string attribute has "a" in the xml. a when I…
tejas
  • 1,795
  • 1
  • 16
  • 34
0
votes
1 answer

Passing QString from parent to child QT

I need in my program to get one QString from parent window to child window. menu=new user(this); menu->show(); This is how I am creating child window. I have QString Username; declared in my parent called "login". This is how I am trying to…
budyb
  • 15
  • 5
0
votes
2 answers

Construct QString from QJsonArray in Qt

While trying to construct a QString from values from a QJsonArray, I get the following error: error: passing 'const QString' as 'this' argument discards qualifiers [-fpermissive]. Dunno where I am getting it wrong in this code: QString…
Dut
  • 39
  • 8
0
votes
1 answer

Template iterator with QString

I had a problem with passing a template iterator of vector<'T> to a function QString::fromStdString(const std::string&). I had my function that in case of type T can convert a std::string to QString or int to QString and than add in into my…
0
votes
1 answer

OpenCV Mat to Qt QString

I'm using opencv in a Qt app. I've seen some generic c++ ways of printing out the values of a Mat and have done so with cout << "myMat = "<< endl << " " << myMat << endl << endl; Ideally I could have a QString with the contents of this Mat. Is…
C Banana
  • 45
  • 9
0
votes
1 answer

how to split \t in Qt text reading

i'm using split to detect some number in a text file in Qt. QString line = my_file.readLine(); QStringList list ; if(file_format=="csv") list=line.split(',', QString::SkipEmptyParts); else list=line.split('\t',…
javad
  • 15
  • 1
  • 8