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

cannot update string in QTableWidget

I want to change for example 2.16 into 2,16 in a table. This is my code { ....... connect(ui.tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(change_string(QTableWidgetItem*))); } void…
trangan
  • 341
  • 8
  • 22
0
votes
2 answers

Ownership of QString with QTextStream

I am trying to use QTextStream to read from a QString. Since the constructor has the following signature: QTextStream(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite) (see the documentation) Since the constructor is passed…
giorgio-b
  • 113
  • 7
0
votes
1 answer

Populate struct with specifc data from QStringList

I have a csv file and some of the text in it is as follows: sendLink, 23, VL_name1, 0.5, 0.5 PATH, (device_1, 1, SW1, 10),\ (SW_2, 23, SW_1, 23),\ (SW_1, 9, device_2, 1) PATH, (device_3, 2, SW_12, 10),\ (SW_12, 23, SW_11, 23),\ …
smyslov
  • 1,279
  • 1
  • 8
  • 29
0
votes
2 answers

Qt: Convertion of a QString from utf16 to utf8

i'm trying to convert some data get from a txt file coded in utf16 to utf8 by using Qt. Could someone help in this? Thank you in advance.
0
votes
3 answers

How can i split a QString by a delimiter and not if that delimiter is somewhere enclosed in square-brackets

If i have a QString in the form of QString s = QString("A:B[1:2]:C:D"); i want somehow to split by ':', but only, if not enclosed in square-brackets. So the desited output of the above QString woud be "A", "B[1:2]", "C", "D" Right now, I can only…
tobilocker
  • 891
  • 8
  • 27
0
votes
1 answer

Transmit QMap by QMimeData

Is any ideas how i can transmit QMap in Drag and Drop mode by using QMimeData? Now i convert QMap into QString like this: "key1:value1;key2:value2;...keyN:valueN" and assigned it to QMimeData::setText(). Then on dropEvent() i…
murzagurskiy
  • 1,273
  • 1
  • 20
  • 44
0
votes
2 answers

Extract character from QString and compare

I am trying to compare a specific character in a QString, but getting odd results: My QString named strModified contains: "[y]£trainstrip+[height]£trainstrip+8" I convert the string to a standard string: std:string stdstr =…
SPlatten
  • 5,334
  • 11
  • 57
  • 128
0
votes
1 answer

AttributeError: 'QString' object has no attribute 'rfind'

My application runs fine in one computer but when I run the same application in another I get the error: Traceback (most recent call last): File "./th.py", line 98, in browse_file2 self.textEdit_2.append(str(os.path.basename(p))) File…
0
votes
1 answer

How to get rid of parentheses and theirs content in a QString?

I am trying to get rid of parentheses and the words contained in these parentheses in a QString. Could you please help me? var1.at(0) = " MainWindow(QWidget *parent) : "; QStringList var2 = var1.at(0).split(QRegExp("\("),…
goGud
  • 4,163
  • 11
  • 39
  • 63
0
votes
0 answers

Python subprocess - user input from C++ executable

I have a C++ code that I compiled into an Windows executable that runs just fine. When I run it, a console pops up and the user is requested to enter a string (the C++ script actually expects a QString by definition). The one line in my C++ script…
user2920100
  • 89
  • 2
  • 7
0
votes
1 answer

How to split QString

I am trying to parse a QString of this form: QString str = "34 t:513 l:21 o:0x0147 [FBI] Miscellaneous No. : 89f2aad996ae4a5c961a 123 532af2"; QRegExp tagExp(":"); QStringList firstList = str.split(tagExp); However I need only "9f2aad996ae4a5c961a…
goGud
  • 4,163
  • 11
  • 39
  • 63
0
votes
1 answer

QString.replace not working

I am trying to process HTML data held in a QString. The data has encoded HTML tags, e.g. "<" etc. I want to convert these to the appropriate symbols. I have been trying a number of approaches but none seem to work, which suggest I am missing…
TenG
  • 3,843
  • 2
  • 25
  • 42
0
votes
1 answer

convert qstring to const unsigned char array

I have a QString string = "131865EDC62E4AC5131865EDC62E4AC5" which is 16 hex-numbers. I need to convert this to something like const unsigned char s[] = {0x13, 0x18, 0x65, 0xED, 0xC6, 0x2E, 0x4A, 0xC5, 0x13, 0x18, 0x65, 0xED, 0xC6, 0x2E, 0x4A,…
yangsunny
  • 656
  • 5
  • 13
  • 32
0
votes
1 answer

How can i split a wchar_t / TCHAR / WCHAR / LPTSTR into a QStringList?

While working with the Win32API, the function i must use returns its results by writing them to buffer of type LPTSTR as well as the individual number of characters that were written.enter code here As this buffer is a string, and the function can…
Andrew
  • 1,344
  • 1
  • 12
  • 20
0
votes
1 answer

Python: use of isalnum() method in QString

I'm trying to check if the user's input is alphanumeric. I tried using isalnum but it always shows this error: AttributeError: 'QString' object has no attribute 'isalnum' what would be the best way to know if a string is alphanumeric in…
eshi
  • 57
  • 7