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
2 answers

QString, remove labels and content?

message.Text() is a QString. I want to remove some text. The text can be: Normal: "This is a text" With a label: "somethingThis is a text" First, I find if the text has the label: !message.Text().contains("",…
legami
  • 1,303
  • 6
  • 22
  • 31
0
votes
1 answer

PyQt QString masks special characters and does not display correctly

I cannot get PyQt to display a string with special characters correctly. From a drag and drop action I end up with filenames as QString that may contain a blank or one of the ugly German Umlaute For simplicity let's consider this is the filename I'd…
MichaelA
  • 1,866
  • 2
  • 23
  • 38
0
votes
1 answer

Qt - How to test whether the text of QTableWidget item is an integer number or not not?

I am working with the Qt and C++. If I have a QTableWidget, how can I test if an item's text is an integer? if(table->item(index, 0)->text().is_integer()) Qdebug("yes is an integer") ; else Qdebug("no is not an integer") ;
SalamBoy
  • 58
  • 1
  • 11
0
votes
1 answer

Can you configure QDebug to automatically output with text formatting, and insert info such as the datatypes or namespaces it is returning?

QString m_BoatProgramming("Boat Programming"); qDebug() << m_BoatProgramming; qDebug() << QDate::currentDate(); Gives me: "Boat Programming" "Saturday 20th, 2016" In some circumstances, rather than going through all the trouble of finding the…
Anon
  • 2,267
  • 3
  • 34
  • 51
0
votes
1 answer

Formatting a string in Qt

I'm using Qt 5.4. I need to format a QString representing a number and make sure that it's always with 3 digits, adding trailing zeros. Let me give an example: If the string is "1" I need "100". If the string is "13" I need "130". If the string…
Alfredo
  • 5
  • 4
0
votes
1 answer

Qt: Unicodes / Utf-8 in QString takes for ever (12 minutes) to display on a controller

I'm doing a multilanguage application with Qt, in Eclipse/Linux. In thai, the line breaks don't seem to be well supported on my controller (I'm still not sure why). Anyway, the following algorithm inserts a zero-width space (\u200b) between each…
Benjamin
  • 53
  • 8
0
votes
1 answer

Is this usage of arg ok?

msg.append(QString("\"settime\": %1000,") .arg(eventList[i].failureBegin)); // set time I would like to know if it`s ok to have %1 right next to 000. Since there is only 1 argument then there is obviously no confusion possible for QString but what…
yan bellavance
  • 4,710
  • 20
  • 62
  • 93
0
votes
1 answer

QString containing printer command in hex

I am working on some printer driver and I am importing printer commands from command specification manual and for instance, printer command Print and Feed Paper has hexadecimal value of 0x0a: #ifndef UECOMMANDSET_H #define UECOMMANDSET_H #include…
KernelPanic
  • 2,328
  • 7
  • 47
  • 90
0
votes
2 answers

Removing FilePath from QStringList

I have a QStringList full of file path. But these file path isn't in normal format, i have environment variable in the file path, for example %PATH_OF_VAR%/GEN/abc.txt. I am using fileName but apparently it doesn't work. What I want to do is, I need…
user5603723
  • 195
  • 2
  • 11
0
votes
1 answer

Inserting string in another string at specific index c++/Qt

I have a QString (it may does not matter since I convet it to std::string anyway) which contains the full unix path to a file. e.g. /home/user/folder/name.of.another_file.txt. I want to append another string to this file name right before the…
Dumbo
  • 13,555
  • 54
  • 184
  • 288
0
votes
1 answer

Qt-append deminal part of float number to long varibale

I have unsigned long a=999999999; and float b=0.123456; and i want to have result in QString as 999999999.123456 what is best way to do this?
0
votes
1 answer

How to add free scrollbar to qlistwidget

I search almost everywhere how to add verticalScrollBar to QListWidget, however I couldn't find suitable answer for my question. I am trying to show output of QProcess to QListWidget. However there is no vertical scroll bar. In my example I have…
goGud
  • 4,163
  • 11
  • 39
  • 63
0
votes
2 answers

How to suppress unicode characters in QString or convert to latin1

Trying to insert some data from CSV to Firebird table in Qt. DB is in ASCII. When inserting some strings with non-ascii symbols get error: Cannot transliterate character between character sets Setting…
Aleksey Kontsevich
  • 4,671
  • 4
  • 46
  • 101
0
votes
2 answers

How do I format a number?

How do I format a number the following way? input: 123 output: 1.2-3 In C#, there's a ToString() overload for integer types that does the job: 123.ToString(@"0\.0-0"); //output 1.2-3 Is there something like this in Qt? I did read QString…
Jack
  • 16,276
  • 55
  • 159
  • 284
0
votes
1 answer

How to print QString in specific line

I knew how to calculate number of lines in Qt through QTextLayout . I want to print each line separately. Here is my code: QTextLayout *Layout = getMessageTextLayout(text,option,Width); for (int j = 0; j < Layout->lineCount(); j++) { QTextLine…
Farzan Najipour
  • 2,442
  • 7
  • 42
  • 81