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

How to associate the selected item of Combobox to write into a file

Basically I have a line-edit box which take the user input such as comma separated values and on clicking the push-button it write all the values of line-edit box to a text file. But same feature I want to achieve through combobox. So whenever one…
Chinmoy
  • 493
  • 1
  • 5
  • 16
0
votes
1 answer

".mp3" metadata from TagLib to QString, Qt, C++

I'm trying to rename .mp3 files using TagLib with the format "artist - album - song(year).mp3" and move them to a new directory, so far i'm using TagLib::FileRef f(dirIt.filePath().toStdString().c_str()); QString newName =…
Jadelabe
  • 37
  • 8
0
votes
1 answer

Get key value from QString which contains JSON

I have a text box, where a JSON string is put. I want to send key-value pairs to a web service. For this I need to parse QString to smth, iterate in this smth, putting key-value to QUrlQuery. QByteArray qba01 =…
Andrii Muzychuk
  • 1,151
  • 3
  • 20
  • 28
0
votes
1 answer

what is the workaround for QString.contains() method for pyqt4+python3?

I have been converting a Qt/C++ widget code into PyQt4+Python3. I have a QFileSystemModel defined and the items it returns have "data" with the filename as type "str". (This is of type QString in Qt/C++ or Python2x). I have to search for a filter…
0
votes
1 answer

conversion from 'char**' to 'QChar' is ambiguous

I am working on a very simple and quick program in qt to convert an entire file to a single line string and prints it out. It is run through the command line. I have one problem. When compiling the program Qt Creator gives me this error conversion…
crank123
  • 251
  • 1
  • 4
  • 17
0
votes
1 answer

Value for a QString showing as byte array in Visual Studio 2010

QString str = "hello"; When I debug the code in Visual Studio 2010 and add a watch to str, I'm unable to get the data it contains as a string. The watch shows only the internal byte array. How can I get the value of a QString as a text string,…
IPS
  • 81
  • 1
  • 12
0
votes
1 answer

distance between QStrings of several words Qt c++

I'm currently trying to compare two strings of several words. I know it's possible to get the distance between two strings with the levenstein algorithm. It's working well. But how can I get the distance between several words? I'm programming an…
Avatar36
  • 79
  • 2
  • 6
0
votes
0 answers

QString.sprintf() returns string withouth formating it

I've the odd situation that something (very rare) QString.sprintf() called with a simple int parameter doesn't seem to work for me: QString debug_str; if( doSomething ) { for( int i=5; i>0; --i ) { LOG_INFO(…
Hhut
  • 1,128
  • 1
  • 12
  • 24
0
votes
1 answer

qstring double quotes and escape character qt

Good afternoon, I want to create a string type : "{\" events \ ": [" in qt 5, but creating **QString (QLatin1String ("\"% 1 \ "")) .arg (str);** does not make me the quote after the { or bar \. Any ideas ?, thanks.
user3723289
  • 1
  • 3
  • 4
0
votes
1 answer

Get first name and last name out of a full name QString

I have a QT Project where I get the full name as a QString variable fullName from user input. I'd like to store the first name (firstName) and last name (surname) in their own QString variables by extracting them from fullName . The user input…
Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
0
votes
0 answers

How to remove C2 A0 in QByteArray before converting to QString?

I have a QByteArray that has "C2 A0" in it that when converted to a QString makes "=C2=A0". I remove this "=C2=A0" and replace it with a space before I send it to be converted to a PDF. Problem is I always get the  in the resultant PDF. I have…
Dave
  • 17
  • 4
0
votes
3 answers

How to get value of a particular field from a string in Qt

How can i get value of a particular query field in Qt. Consider the following string "plugin://plugin.video.youtube/?action=play_video&videoid=4fVCKy69zUY" I want the value of videoid i.e 4fVCKy69zUY in form of a string how can i do this.
Eljay
  • 941
  • 5
  • 15
  • 30
0
votes
2 answers

String to char * conversion for special character

I have wrote a simple function in C++/Qt to transform QString to char*. The function is working fine but I had some issues on some specific character. for example "piña colada" as the QString Parameter is transformed to "pi?a colada". something…
Seb
  • 2,929
  • 4
  • 30
  • 73
0
votes
1 answer

Word highlighting in Qt using QRegExp

I am trying to highlight a searched word using QRegExp. This is the code. QString text = "A bon mot."; text.replace(QRegExp("([^<]*)"), "\\1"); //Output: "A bon mot." The above code is working, but the below code is not…
Pamba
  • 776
  • 1
  • 16
  • 29
0
votes
1 answer

QList operator<<

I have a QList element named competence inside a class, and another class object named k. I want to make a deep copy( this.competence must be a deep copy of k.competence ). I use an iterator it: QList< QString>::iterator it; for( it =…