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

Substract two QString

I´m trying to substract two hours. QString 1 = "11:00"; QString 2 = "10:00"; I would like to save the result from (11:00 - 10:00) into another QString. Does anyone know how could I do this? Thanks for replying!
Alberto7
  • 51
  • 1
  • 7
0
votes
1 answer

Apply internationalization to a QString containing html

I need to create a QString that contains html. I want to internationalize it... adding QObject::tr() How can I combine it ? At this point, my string is like this... I don't think I can apply tr to he entire string, or I'd end up with odd words for…
Thalia
  • 13,637
  • 22
  • 96
  • 190
0
votes
2 answers

Split QStringList element into more elements

I have a QStringList with many elements, for example: sl.at(i) = name:VAR1 size: 8 Decription:fdgag; how can i split this line into more lines? I want to split line by line into more lines with for-loop. thats what i have: for(int i = 0; i…
mc307
  • 19
  • 1
  • 4
0
votes
0 answers

openCV and unicode file name

I have a Qt application in which I open/choose a video file with : QString fichier=QFileDialog::getOpenFileName(…); Then, I need to read this video with openCV with : string str= fichier.toStdString(); const char* c_videoFile=str.c_str(); capture =…
SteveTJS
  • 635
  • 17
  • 32
0
votes
0 answers

PyQt string split returning an memory address rather than the string split

Hello I am having an issue with PyQt when it comes to splitting an string. I am currently grabbing the input text from a TextEdit field and splitting the string inputted into a list. start_token = self.serialInputText.toPlainText() …
JeanP
  • 406
  • 9
  • 27
0
votes
2 answers

Style of html integrated Qstring

I have QSting object: QString someString = "some text" and QLabel object: QLabel someLabel. with this text: someLabel.setText(someString); I set property for QLabel: someLabel.setProperty("class","someID"), and in CSS…
Nicholas
  • 147
  • 1
  • 2
  • 6
0
votes
2 answers

qDebug outputs QString UTF-8 non-Ascii symbols as like \uxxxx

I am trying to convert string (QString) in unicode to utf-8. qDebug prints string like this: "Fault code soap:Client: \u041F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C \u0441…
Pustovalov Dmitry
  • 998
  • 1
  • 9
  • 25
0
votes
1 answer

Qt4: how to send QString inside a struct via QSharedMemory

I have a struct struct control_data{ int column_number; QString cell; }; I need to send it to another thread with the help of QShareMemory. I read that you can't do this because QString contains pointers inside. Any other ways?
r_spb
  • 75
  • 1
  • 14
0
votes
0 answers

Get the text data from QByteArray

I have a such problem: I develop a simple database (PostgreSql). One of the features that it keeps in column (column name: "ascii") a big text data (2000 rows) that reads from file (datatype in the table is BYTEA). Here is the example of the code…
lazexe
  • 367
  • 4
  • 19
0
votes
2 answers

Load an image in hard disk using OpenCV and Qt

I am new using Qt and OpenCV. I am trying to read an image in my HD and show it. It is not a specific image, the program could read any image that user select. My code: QString Imagename = QFileDialog::getOpenFileName( this, …
0
votes
1 answer

Qstring error. Saving from Textpool to string

I've been trying to make simple 'typing game' where program is checking if input = showcased word. I'm trying to use Qt GUI, so I've placed two text widgets, and "play" button. However, there is a problem with string (or QString). Error: no match…
Nars
  • 3
  • 3
0
votes
1 answer

How to pass QString variable to QFile?

getData gets the chosen file from a QTreeView and displays it on label 'test', enables the 'Apply' button, which when clicked calls setTheme void OptionsDialog::getData(const QModelIndex &index) { QString selected = model2->filePath(index); …
user3891489
  • 51
  • 5
  • 8
0
votes
2 answers

C++ QT Getting part from QString

I have custom(dynamic QString) for example something like this 123+555 and i need to get this after +.Also there can be something different then + (/,*,- etc.). My question is how to get part of string after some char.
Wiruspwns
  • 1
  • 3
0
votes
1 answer

Optimizing loop that has QString manipulations

In my project, I wrote a function to decompress a QString that is compressed using a very basic compression format I wrote in a seperate function. But after some testing, I've found this function to be the thing causing massive slowdowns since it is…
mrg95
  • 2,371
  • 11
  • 46
  • 89
0
votes
0 answers

Cannot Convert QString to const Char *

I need to convert QString to const char* then have to pass to another function My code looks, QString port = "1234"; const char *Port = port.toLatin1().data(); setport(Port); //function call Function void setport(const char *Port){ int p =…
Haris
  • 13,645
  • 12
  • 90
  • 121