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
5
votes
1 answer

Question about a QList in Qt

I'm using Qt 4.5 and im working with a QList which is a list of string list. Now I want to replace one string inside one stringList but with it seems unusual to type. I have found the following way of doing it and was wondering if it…
yan bellavance
  • 4,710
  • 20
  • 62
  • 93
5
votes
2 answers

How to use std::string in a QLineEdit?

I have the following problem. I am trying to integrate a large code written by me with a Qt interface. Some of my functions return std::string. I did not succeed in making QLineEdit::setText accept them (other functions returning char do not give me…
Giuseppe
  • 625
  • 1
  • 9
  • 15
5
votes
6 answers

Qt UI for existing C++ project

I have already written a C++ program and I would like to write a GUI for it. I realize Qt is a wonderful tool, however, Qt has it's own classes, which make me quite confused. eg: instead of String, Qt has a class named QString.. I am wondering if I…
Lily
  • 5,872
  • 19
  • 56
  • 75
5
votes
2 answers

QProcess and command line "/c" argument

I have very strange problem with QProcess and it's strange behaviour. What i wanna get at the end is something like this (this is cmd.exe in windows 7) C:\path_to_somewhere>cmd /c "C:\Program Files\path_to_dir\executable" (cmd is for compatibility…
Jakub Chromiak
  • 593
  • 1
  • 5
  • 15
4
votes
2 answers

Converting a QStringList (PyQt) into a normal python list

I want to take each element within a qstringlist and get the raw data from the list not whatever pyqt is storing it as. def find(self): self.foundFileList.setRowCount(0) fileName = self.inputFileName.currentText() path =…
DamianJ
  • 419
  • 2
  • 8
  • 18
4
votes
1 answer

Using Qstring::toDouble To check data

I'm trying to validate user input by using the QString::toDouble() function. The documentation says the function should be used like this: double QString::toDouble ( bool * ok = 0 ) const; /* Returns the string converted to a double value. …
Wylie Coyote SG.
  • 1,009
  • 6
  • 22
  • 37
4
votes
6 answers

Decoding printf statements in C (Printf Primer)

I'm working on bringing some old code from 1998 up to the 21st century. One of the first steps in the process is converting the printf statements to QString variables. No matter how many times I look back at printf though, I always end up…
CodingWithoutComments
  • 35,598
  • 21
  • 73
  • 86
4
votes
2 answers

QString and german umlauts

I am working with C++ and QT and have a problem with german umlauts. I have a QString like "wir sind müde" and want to change it to "wir sind müde" in order to show it correctly in a QTextBrowser. I tried to do it like this: s = s.replace(…
punkyduck
  • 669
  • 2
  • 9
  • 17
4
votes
0 answers

Rationale behind QString plus operator returning const

Is there a rationale why the + operator taking a QString returns const QString instead of QString? This is different to the + operator for std::basic_string. I assume this choice for QString was made delibrately and is probably documented somewhere,…
fabian
  • 80,457
  • 12
  • 86
  • 114
4
votes
2 answers

How can I partition a QByteArray efficiently?

I want to partition a QByteArray message efficiently, so this function I implemented take the Bytes, the part I want to extract, and toEnd flag which tells if I want to extract part1 till the end of the array. my dilimeter is spcae ' ' example if I…
gehad
  • 1,205
  • 3
  • 12
  • 17
4
votes
2 answers

Qt: How to subtract two QSet of QString in case insensitivity mode

I'm working on a logical problem using Qt. I've got two QSets of QString: QSet set1: [ "aaa", "BBB" ] QSet set2: [ "aaa", "bbb", "ccc", "ddd" ] I want to subtract set1 from set2, so I use: set2.subtract( set1 ); And I…
Gildas
  • 1,158
  • 1
  • 10
  • 25
4
votes
2 answers

Converting QString to float gives me errors

I'm trying to convert a string to float and vice versa but the compiler complains about it. In the editor I get implicit conversion increases floating-point precision: 'float' to 'double'. but I'm not converting a float to double at least not as…
Not Amused
  • 942
  • 2
  • 10
  • 28
4
votes
1 answer

Convert QString Unix epoch time to QString standard time

I need an elegant C++ function that takes a QString parameter containing the unix time (e.g. 1295874681) and converts it into standard time format (e.g Mon, 24 Jan 2011 13:11:21 GMT) containing QString and returns it.
yolo
  • 2,757
  • 6
  • 36
  • 65
4
votes
2 answers

How can I print a QString containing a special character with python using PyQt?

I do not managed to simply print a QString variable containing a special character. I always get a UnicodeEncodeError: 'ascii' codec can't encode characters in position .... Here is the code I tried without success : var1 = "éé" #idem with…
oaimac
  • 784
  • 2
  • 12
  • 27
4
votes
2 answers

Converting QString to Ascii value & Vice Versa in Qt

I have a QString StrData = "abcd" and I want get the Ascii value in hex of that string and Vice Versa. For example from "abcd" to "61 62 63 64" and from "61 62 63 64" to "abcd" I manage to get the Ascii value in hex but don't know how to get it…
zhanfeng
  • 43
  • 1
  • 1
  • 3