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

Passing rvalue reference to QVariant does not work with QString

I am trying to return a rvalue reference from a function to a QVariant. It works for bool and int, but when I pass a string I get an 'invalid' QVariant. My function: QVariant &&AudioSettings::getValueFromTable(const QString &name) { QSqlQuery…
Szpaqn
  • 545
  • 5
  • 17
0
votes
2 answers

How I can get the Qstring from unsigned char*?

I am making my Qt program with C++. I am reading a value from a card Reader but its libraries gives me the value with an unsigned char*. And I needit in Qstring to put it in a QTextEdit. I have tried: char*…
Roger Coll
  • 117
  • 1
  • 3
  • 12
0
votes
1 answer

shuffling elements in a QStringList

In my Qt c++ application I have a QStringList containing a set of QString values! I want to shuffle(change the positions of the QStrings in the QStringList arbitrarily) . Is there any default function like "shuffle_array" API in perl? If not how can…
Kushan Peiris
  • 167
  • 3
  • 15
0
votes
2 answers

Fit QLabel height without WordWrap

I need to do a manual word wrap because the native wordWrap from Qt splits in wrong places. I've already done the wrap to my text, but the content wasn't showing all the content. The QLabel was cutting the top and the bottom like the image: Can I…
0
votes
0 answers

QString to double long float and long long int

Is it possible to convert the part before the decimal point to long long int and the part after the decimal point to long double float? Example: QString "1101.110"; and I would like to change that into two variables: long long = 1101 long double =…
Tomaž
  • 59
  • 1
  • 2
  • 5
0
votes
1 answer

KeyError when using QString

I want to execute hash algorithm. So, I made this code. I also imported hashlib. But, in the last line, an error happened: KeyError: PyQt4.QtCore.QString(u'sha1') I don't know what the problem is. Here is the code: def setupUi(self, MainWindow) …
Layla
  • 51
  • 9
0
votes
1 answer

Convert Binary QString to QPixmap

I'm receiving a binary thru FTP and storing it as a QString. The original image was BMP but to pass through FTP I converted it to QPixmap. I'm able to successfully receive this binary but I can't convert back to a QPixmap or some sort of format to…
user8057102
0
votes
1 answer

QString shows garbage value while showing single quotes in QT 5.9

In Qt 4.8 this was working fine. QString test = "this is a test message for special characters ‘sk’ @#$%^&*()"; qDebug()<<"test message"; qDebug()<< test; But in QT 5.9 I am getting a REPLACEMENT CHARACTER . Output in Qt 4.8 test…
sk110
  • 77
  • 2
  • 9
0
votes
0 answers

QT: Runtime error reading text file in QStringList

with my application in Qt I'm currently trying to read a really big formatted text file (20.000.000 of lines) and collecting data in some QStringLists (plural). Each lines generates 4 QStringList components of 10 characters each. Always at the same…
piepolitb
  • 31
  • 4
0
votes
1 answer

When I save my json with accent I have wrong text (Qt)

When I want to create a save in json format (Qt), I use the french accent é : I have this character instead of éro original (QString) : "sauvegarde numréro 1" saved (in the json): "sauvegarde numéro 1" ps: "sauvegarde numéro 1" means…
John Smith
  • 133
  • 2
  • 12
0
votes
1 answer

QT customplot not correct

I am trying to plot graph from the CSV file of airfoil. I am able to store value in and array of QStringList and plot it. But, there is an abrupt jump at zero value. I have seen the output in qDebug it shows correct value. Please help. I can't…
0
votes
2 answers

Qt stylesheet and QString::arg()

To keep a Stylesheet dynamic regarding DPI settings, I want to set certain parts of it from code. This works: my_label->setStyleSheet( QString( "font-size: 30px;" ) ); Yet, this doesn't: my_label->setStyleSheet( QString( "font-size: %1px;" ).arg(…
i know nothing
  • 951
  • 1
  • 10
  • 27
0
votes
0 answers

QString compare with digits

I'm looking for a comparison function between QString that take in account digits. For example: std::vector init { "test22", "test4", "test1", "test10", "test2" }; If I use basic QString::compare, it sorts the list like: "test1", "test10",…
Tony
  • 1
0
votes
2 answers

QChar to uint32_t conversion / casting in Qt

I have a QString of 1500 QChar which I want to convert to an array of uint32_t. I am reading each element in for loop and trying to save each QChar of QString to uint32_t array. I can convert it to its equivalent representation (e.g. 1 -> 49)…
aly
  • 17
  • 5
0
votes
1 answer

How to set umlaut for header in QTableWidget?

I have this command to set label for all headers of a table: ui.mytable->setHorizontalHeaderLabels(QStringList() << tr("VERTRAG") << tr("DATUM/UHRZEIT") << tr("PRÜFER")); But this Ü does not appear. I tried to…
gnase
  • 580
  • 2
  • 10
  • 25