Qt Creator Debugger Goes to QString Code

When debugging with Qt Creator every time I enter a method with a QString parameter as a parameter, I get some annoying qstring.h code:

// ASCII compatibility
#ifndef QT_NO_CAST_FROM_ASCII
inline QT_ASCII_CAST_WARN QString(const char *ch)
    : d(fromAscii_helper(ch, ch ? int(strlen(ch)) : -1))
{}

Is there a way to avoid the debugger to go to qstring.h?

Change 1

My pro file:

QT       += core
QT       -= gui
TARGET = ConsoleTest03
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp

My code is:

#include <QDebug>
#include <QString>

void display(QString s)
{
    qDebug() << s;
}

int main(int argc, char *argv[])
{
    display("coucou");
    return 0;
}

Edit 2

I am using Qt 5.1.1 and Qt 3.0.1.

+4
source share
1 answer

You get there because you call this constructor in your code.

display("coucou");

which actually causes

display(QString("coucou"));

and QString (const char *) is not what you really need to do. http://qt-project.org/doc/qt-5/qstring.html#QString-8 .

,

QString str(QLatin1String("coucou")); // you don't really need QLatin1String
                                      // if you are happy with 'const char*' constructor
display(str);

QString display(). (), Step In Continue.

QString, QString, . , "". , - , () - ,

#include <QDebug>
#include <QString>

void display(const QString &s)
{
    qDebug() << s;
}

int main(int argc, char *argv[])
{
    QString str(QLatin1String("foo"));
    display(str);
    return 0;
}

, , .

+1

Source: https://habr.com/ru/post/1532319/


All Articles