799 questions
Score of 1
4 answers
233 views
How to convert std::filesystem::path to QString
I am currently working with QPixmap to set an image to a label, but improvising a way around since my qrc file isn't working. I am trying to access the image folder in the project directory and trying ...
Score of -1
1 answer
59 views
qt convert number Not compliant with prefetching
I hope the value of str is 1.235.
But in fact, the value is 1.234 by qt. Why?
What happened in theory?
double d=1.2345;
auto str=QString::number(d,'f',3);
Score of 0
0 answers
141 views
In Qt6, how do you set the encoding of a QTextStream to "EUC-JP"?
How do you set the encoding of a QTextStream to "EUC-JP" ?
The setEncoding function uses this enum:
class QStringConverter : public QStringConverterBase
{
public:
#endif // Qt 6 compat for ...
Score of 2
1 answer
107 views
Why does my attempt to convert QString to unsigned char add random characters? [closed]
I have a QString which stores a hashed input via the line
hashedPass = QCryptographicHash::hash(input.toLocal8Bit(), QCryptographicHash::Sha256).toHex()
I am trying to convert this code to an ...
Score of 0
1 answer
382 views
Changing _qs to _s in Qt6.8
I need to change from operator""_qs to operator""_s, thanks to Qt 6.8. The following code compiles
// notice no includes or using namespace of any kind
auto const label = u"...
Score of 1
0 answers
97 views
In Qt, how do you determine a file's proper encoding, and subsequently load it into a QString?
Backstory ( You can skip )
Building a sgml parser
Testing it with every html document on my computer locate *.html > /tmp/htmldump
Coming across a lot of different type of documents:
file "...
Score of -1
1 answer
146 views
When constructing an empty QString in Qt, which way is the most efficient?
When constructing an empty QString in Qt,
QString()
QString("")
QLatin1String()
QLatin1String("")
QLatin1StringView()
QLatin1StringView("")
QStringLiteral()
...
Score of 0
2 answers
205 views
Is there an efficient way to pass a list of args to a QString, by avoiding copies?
Lets say I have a list of N arguments which I want to pass to a QString. The number N is variable and determined at runtime.
If I do this:
QString myString = "Some text %1, some other text %2,...,...
Score of 0
0 answers
83 views
Why is QT Creator Automatically Splitting my String While Reading the Data from a STM32 Microcontroller?
I have been trying to send some temperature values read by 2 sensors connected to STM32 Microcontroller. I have already programmed the mc to send just 2 lines of temperature values (vertically and ...
Score of 0
0 answers
144 views
How can I escape all unicode characters in a QString so that only ASCII is used and the result is as short as possible?
I'm searching for a safe method to escape all non-ASCII characters in a QString (and of course to un-escape them later) that will result in pure (printable) ASCII but yield the shortest possible ...
Score of 0
1 answer
143 views
How to access property for NumberAnimation and animate latter QML from first QML?
I have two qmls among which one contain animation say animation.qml and one contain data say data.qml.
I want to run my animation.qml for animating the content inside data.qml for that purpose I want ...
Score of 0
0 answers
75 views
Can a QString be shared between two Qt containers without being deep-copied?
Say I have the code below.
QSet<QString> set;
QList<QString> list;
QString str("hello");
set.insert(str);
list.append(str);
Question: Is the QString deep-...
Score of 2
0 answers
707 views
Error "passing 'const QString' as 'this' argument discards qualifiers]" in QMap::insert method
I am making XmlReader and still don't know well where to use const modifier. With this code:
const QMap<const QString, const QString> XmlElement::readDomAttributes(
const QDomElement&...
Score of 0
0 answers
65 views
QString.split missing some empty lines
I'm stuck with this. I am trying to tokenize a multiline QString and count the number of lines.
QStringList sentences = m_text.split(QRegularExpression("\n|$"), Qt::SkipEmptyParts);
qDebug() ...
Score of 0
1 answer
171 views
Cleanup a QString from garbage even if it starts with a null char
Using the QtOpcUa library I read a "string" from a PLC. The retrieved data is a QVariant:
void MyClass::opcua_valueChanged(QString key, QVariant value)
{
qDebug() << value;
}
here ...