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 properly display unicode symbols on Linux using QT?

I want to add an Unicode Symbol as a list widget item in QT. (Particularly this item : http://www.fileformat.info/info/unicode/char/25B6/index.htm ) I'm using following method for this : this->addItem( new QListWidgetItem( …
Maverick33
  • 337
  • 3
  • 15
0
votes
1 answer

How to make QString::fromLocal8Bit as default?

I'm using Qt 5.3.0. I need to add some Japanese characters into my code. I already add BOM but I still have to use QString::fromLocal8Bit to make characters to correctly be displayed. For example: I have a pushButton and I call…
user3819226
  • 461
  • 1
  • 5
  • 17
0
votes
1 answer

Hex QString to hex qByteArray

I am trying to implement an OTP generator for Blackberry OS10. I already use the reference implementation on Android side, you can find it here: So I would like to convert it to C++ / QNX code and I have some troubles with hexadecimal…
0
votes
1 answer

Opencv using imread and vector of QString filenames to load images

I have been trying to read some images in a loop using imread into a vector of Mat (images) with opencv by getting the filenames from a vector of QString but it will not compile. I know it's the format of my QString that's the problem but cannot…
omegaFlame
  • 245
  • 3
  • 9
  • 21
0
votes
1 answer

Wrapper for converting std::string to QString?

I have QT_NO_CAST_FROM_ASCII defined so I cannot cast from a char* to a QString. Previously I've been using: QLatin1String But I just noticed QString::fromStdString, I don't like using this because QLatin1String is preferred to…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
0
votes
3 answers

using std::string with Qt causes run-time error on destruction

I have a Qt app that uses another library where the function output is std::string instead of a QString. So in my program I have a method void doSomething() { ... std::string std_string = MyExternalLibraryThatReturnsSTLstring.getString(); QString…
Magus
  • 87
  • 1
  • 6
0
votes
1 answer

QStringList::split - split a long string with data into many different QString

I have a long list of data that contains data as follows: "floatingnumber1a:floatingnumber1b,floatingnumber2a:floatingnumber2b,floatingnumber3a:floatingnumber3b" I have them as a QString. Now I want to split them in two different arrays - one that…
smaica
  • 723
  • 2
  • 11
  • 26
0
votes
1 answer

Why is QString::number() ignoring most significant digit?

This confuses me quite a bit. What's the deal in the example below? I'm running this on an armv7 architecture, I've seen some posts online saying that arm doesn't support doubles the same way that an x86 architecture does, but still I'm using an…
Joey Carson
  • 2,973
  • 7
  • 36
  • 60
0
votes
2 answers

output to console of a random string list Qt

I wrote a program to output a random quote from a QStringList to a console window, program runs but I can't figure out why nothing appears in the window. Please help here is the code: #ifndef RANDOMADVICE_H #define RANDOMADVICE_H #include…
Dmon
  • 220
  • 4
  • 15
0
votes
1 answer

QT error in connecting passing a QString element

I was following some code posted in other questions on how to connect the status bar between parent and distant child by means of signals and slots. MainWindow::MainWindow(QWidget *parent) : …
Francesco
  • 481
  • 2
  • 4
  • 16
0
votes
2 answers

Regex with Qt capture some text

I would like to capture second occurence of the text replaced by a star in the following string:  SW *
ie string starting with  SW ending with
in a QString, using the RegEx with Qt. an example here: the string is…
kiriloff
  • 25,609
  • 37
  • 148
  • 229
0
votes
1 answer

Convert Qstring using QList to double

I want to convert the Qstring in the QLineEdit to double using QList so that it could perform a calculation and display the results in the QMessagebox. If I can get some suggestions on how this can be done it would be great. #include…
user1291092
  • 105
  • 4
  • 9
0
votes
1 answer

QString empties while passing to function

I have a project written with QT. So far I tested it in Windows without problems. Today I tried to port it to Linux I downloaded the Qt source tree from qt.gitorius.org. For now it have version 5.2.2. It compiled and installed without…
folibis
  • 12,048
  • 6
  • 54
  • 97
0
votes
2 answers

Python encoding error when trying to print a QString

I try to print a PyQt4.QtCore.QString object: print str(type(html)) print str(html) However, I get the following error: Traceback (most recent call last): File "download.py", line 23, in print…
toom
  • 12,864
  • 27
  • 89
  • 128
0
votes
1 answer

Conversion from QString to hex

I have the same code in 2 different projects. The Qstring::number(data.toLong(&ok,2),16) works in one project and in the other project it does not work. Does anyone know what the reason could be? The code is as follows 1) unsigned short status; 2)…
nkp
  • 13
  • 6