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

Display japanese string in qt and qml

I have a QString which contains a japanese string. But while debugging its just showing "???" in place of string. I need it to display it in qml. I have used QtextCodec but didnt work for me. Please give any solution or suggestion to fix the issue.
Anoop AR.
  • 118
  • 1
  • 12
0
votes
1 answer

How to make QString convert figures with fixed precision?

I use tr("%1").arg(2.00000, 0, 'f', 2); to format figures. it is formatted to "2.00", but '.00' is not what i want, i hope to cut it off. so i tried .arg(2.00000, 0, 'g', 2);, and the '.00' is cut. but in some other curcumstances 'g' mode uses 'e'…
zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
0
votes
2 answers

Qt char* to QString

I am trying to convert char* to QString. It should be a trivial task but the problem is, I am having the following input: item char [512] "N" char [512] [0] 78 'N' char [1] 0 '\0' char [2] 73 'I' char [3] 0 '\0' char [4]…
Murtuza Kabul
  • 6,438
  • 6
  • 27
  • 34
0
votes
1 answer

Qmake giving me error

I'm trying to convert a string into a short int by using: short tempS = QString("%1").arg(arguement); where argument is a QString. however I'm getting the error: crosses initialization of short int tempS
Amre
  • 1,630
  • 8
  • 29
  • 41
0
votes
2 answers

QChar::isLetterOrNumber() fails

I want to convert QStrings into filenames. Since I'd like the filename to look clean, I want to replace all non-letters and non-numbers by an underscore. The following code should do that. #include #include QString…
Johannes
  • 2,901
  • 5
  • 30
  • 50
0
votes
1 answer

Qt4: debugging with popups, trying to convert integer to string, getting letters

Sorry for the confusing title, what I am trying to do is use Qt to count the amount of elements with a certain tag name. When I do this, and try to convert the count to a string I get letters instead of numbers. void xml::list(QDomElement root,…
PinheadLarry
  • 117
  • 1
  • 7
0
votes
3 answers

Qt array QString

I get result from db by selectall query and I want save result in array and send it by socket. db.open(); QSqlQuery *selectall = new QSqlQuery(db); selectall->prepare("select * from phone_table"); selectall->exec(); selectall->first(); QString…
developer
  • 37
  • 1
  • 6
0
votes
1 answer

QString with text and an image

Is there a way of inserting an image in a QString? I need to have a QString this way " 'image' some text" It needs to be a QString since i'm inserting it in a QPaint event and i cant use a QLabel for that (because i can't insert a qlabel into the…
acerqueiro
  • 29
  • 5
0
votes
1 answer

Qt QString "key-value" replace from QHash

I have a QString with content that looks something like this: "resolution=[imagesize]&quality=[imagequal]". And I have a QHash mDefaults container that holds a list with some of my 'key' values. ("imagesize" and "imagequal" are so…
Gediminas
  • 1,830
  • 3
  • 27
  • 47
0
votes
2 answers

paint text with paintEvent()

i have a program that needs to paint some text with paintEvent(). i've tried this: 1. QPainter painter; // painter for the canvas 2. painter.drawText(QPoint location, QString canvasText); where 3. QString canvasText = variablesText.append("< b…
acerqueiro
  • 29
  • 5
0
votes
3 answers

QString to const std::string

I want to assign the value in QString to a const std::string QString qfile("some value"); this is the const std::string variable const std::string file The code that I m using file = qfile.toStdString(); above codes works fine for a normal…
Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126
0
votes
2 answers

Concatenate stl string+int+int+int in QString

Possible Duplicate: Concatenating two QStrings with an integer i'm looking forward to create a a string from 3 ints and one c++ stl string in QT, how can i do this? anyone know?, can't find something thats explain this procces? this is my code…
Bogdan M.
  • 2,161
  • 6
  • 31
  • 53
0
votes
2 answers

Get path of file in external library

I have 2 Qt projects that I've made. One builds a library the other builds a GUI that uses that library. My project with the library includes a bunch of shaders that I've made. Within my GUI I want to reference the path to these shaders. My…
user869525
  • 769
  • 2
  • 12
  • 21
0
votes
3 answers

Is the QHash::contains method case-sensitive or case-incensitive?

I have a QHash. I use the following expression to check whether a value is there in the QHash::keys() or not. //programme QHash samplehash; QString value = "somevalue"; if(samplehash.contains(value)) // Condition -…
Ajay
  • 9,947
  • 8
  • 32
  • 34
0
votes
1 answer

Qt C++ initialize a QStringList class member

I have a class member of type QStringList. I had a guess that when this class is instantiated, nex instance get such a QStringLsit with no elements in it. I have a function that should fill in this QStringList on user interaction. However, I see…
kiriloff
  • 25,609
  • 37
  • 148
  • 229