On 17.03.25 20:09, Jøger Hansegård via Development wrote:
[...]
> I agree that it would be nice to have a compiler error but given that
> QStringList behaves the same way as std::vector, I am not sure it is a bug.
For the specific case of QList, we could take first and last by
reference, prevent
Thanks for your answers! So it's a lethal combo of string literals and
iterators, something to keep in mind when writing C++.
Rgrds Henry
n 2025-03-17 20:09, Jøger Hansegård wrote:
Obviously I am doing something wrong when setting o4 but it would be nice if I
could get a compile error...
Hi
On Monday, 17 March 2025 13:39:42 Pacific Daylight Time Mathias Hasselmann via
Development wrote:
> To avoid bloating you code with QString{}, QStringLiteral{} or
> QLatin1String{} boilerplate after enabling QT_NO_CAST_FROM_ASCII you
> also might consider using UTF-16 string literals (u"your text"
I really want to highlight Igors advice to define QT_NO_CAST_FROM_ASCII.
It really removes countless traps when using Qt, and will give you a
much more pleasant experience.
To avoid bloating you code with QString{}, QStringLiteral{} or
QLatin1String{} boilerplate after enabling QT_NO_CAST_FROM
> Obviously I am doing something wrong when setting o4 but it would be nice if
> I could get a compile error...
Hi Henry,
Yes, this recently confused me as well, and here is what I found:
The issue is that QStringList("g","goessouth") behaves the same way as
std::vector(“g","goessouth"). In b
Hi,
This is a really unfortunate (and all too common) case...
o4 is invoking the QList(InputIterator, InputIterator) constructor, with
the `InputIterator` type being deduced as `const char *`. This is a
valid iterator type with traits specialization and everything, so this
constructor is a me
Hello, there are a more than one way to initialize a QStringList but
sometimes they are not equal, consider this console app:
main.cpp:
#include
#include "qcommandlineparser.h"
#include "qdebug.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QCommandLineParser lp