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
-2
votes
2 answers

Return QString value from void method inside a class

file.cpp fileTxt::fileTxt() { } fileTxt::~fileTxt() { } void fileTxt::setFileTxt(Ui::Dialog *ui) { QString fileName="test.txt" } void fileTxt::elabFileTxt(Ui::Dialog *ui) { ui->label_7->setText(fileName); } i have two methods inside…
Massimo D. N.
  • 316
  • 1
  • 6
  • 17
-2
votes
1 answer

Qt ASSERT failure in QList::at: "index out of range

I have been using QString lists in my program but they are breaking when i change the index of my combobox for a second time (By Breaking I mean that the program is crashing) and i'm unsure why. the only code that is using QStringLists is void…
Root0x
  • 113
  • 1
  • 2
  • 12
-2
votes
2 answers

Qt How to compare a text from textEdit

I have two QTextEdit objects. In my first QTextEdit object, I have set the text. In my second QTextEdit object, I have to type in the text. I want to compare the two texts something like this: if(ui->textEdit2->toPlainText() ==…
Tr4in
  • 117
  • 1
  • 4
-2
votes
2 answers

How to compare two QString arrays Qt C++

i want to compare two QString Array with Qt and C++, i tried this, but it dosent work, (in fact my application crash...) : if(ArrayOne[nb] != ArrayTwo[nb]){ } And then i need to assign a value at an element of my array, but i dosent work too…
Random78952
  • 1,520
  • 4
  • 26
  • 36
-3
votes
0 answers

A string of type QString (Lao) is displayed as "?", how can I fix this?

I think it's an encoding problem. I try to convert from UTF-8 to QT's string type, but it still doesn't work. How can I solve this problem? #include #include #include int main(int argc, char…
yong57
  • 1
  • 2
-3
votes
2 answers

How to change the font and color of QString?

I have a QString like this ">>> This is an Arrow." , now I want to have >>> in bold and red, How to do that ? i have looked over some pages and found this syntax QString redPart = QString("%1").arg(">>>"); but…
the_learnist
  • 69
  • 1
  • 8
-3
votes
1 answer

if QString contains a number

I want to know if a string contains a '1' or '0' so I wrote this code: if ((input.contains('0'))||(input.contains('1'))) { ui->answerbox->setText(QString::number(BinToDec(number))); } else { …
Tomaž
  • 59
  • 1
  • 2
  • 5
-3
votes
1 answer

How can i get all the text until a space don't come in Qstring?

Hello i want to get the ultil the space in line occur for example in the given picture am able to get the whole string using getter method to my parent window but i dont want get the date time part am currently getting…
-3
votes
1 answer

How can I combine two QStrings into one?

I try to add two QStrings into one. I've read a lot about: QString NAME = QString + QString but this doesn't helps me here. Thats how my code look so far: test.h #ifndef TEST_H #define TEST_H #include #include #include…
Jan
  • 111
  • 1
  • 2
  • 4
-4
votes
1 answer

What is the last part in Qt QString Remove?

I have a code like this: ui->labelRead->setText(QString::fromUtf8(pData).remove(cDataLength.toInt(),8)); I read data from stream and put into pData. I know my data length is 16 character. Now in above code there is a number (8). What is it? When I…
NTMS
  • 816
  • 7
  • 22
-8
votes
2 answers

Error while using += operator in Qt

I create a small app in Qt Creator. I wanted this code in my QDialog constructor, but it doesn't work. std::string wyniki = "apg -q -n " + n + " -m " + m + " -x " + sx + " -a " + a; if(exclude != "") wyniki+=" -E " +…
TN888
  • 7,659
  • 9
  • 48
  • 84
1 2 3
52
53