Skip to content
  • 0 Votes
    2 Posts
    1k Views
    R

    QString can handle having an embedded null character (0x00) whereas C strings would treat this a terminator. I can't tell from your screenshot but likely the character where it is truncated is a null byte.

    Probably the data is lost when you construct the std::string as constData() returns a pointer to char. You should use the method toStdString() instead.

    I am not sure if std::string can contain a null character but I suspect it can.

  • 0 Votes
    3 Posts
    3k Views
    A7VictorA

    @mcosta Hi,

    I'll certainly take a look at it. So I guess it's not only changing the font xD

    Thank you.

  • 0 Votes
    3 Posts
    5k Views
    p3c0P

    @RDiGuida To add to @Mario84's answer, QString is Qt based class and your using standard c++ API's to print it which it doesnot understand. To print values of pure Qt based API's you can use qDebug().
    Eg:

    QString dt ((dates[0]).toString()); qDebug() << dt;
  • 0 Votes
    4 Posts
    5k Views
    Chris KawaC

    From a design point of view it's not ugly. It's actually prettier.

    For example if you have a class Triangle or APieceOfRock they have conceptually no debugging or to string conversion notion whatsoever.
    Why should a triangle or a piece of rock know anything about strings or how to convert to them? Should it also convert to other data types like ACar or QWidget? Should you add a conversion method to them every time you introduce another type in your app? Making toSting() method in every class is pumping in it functionality that is out of their purpose scope and does not belong to that class.

    A separate utility function, detached from the class is actually a much cleaner solution that keeps responsibility separation.