David Polák
David Polák

Reputation: 1691

Qt - getting "warning: format not a string literal and no format arguments"

Keep getting warnings on lines like these

qDebug("An error occured while trying to create folder " + workdir.toAscii());

workdir being QString()

warning: format not a string literal and no format arguments

Upvotes: 7

Views: 4217

Answers (3)

Amin Kh.
Amin Kh.

Reputation: 131

I managed to get it to work fine without warning like this :

qDebug("An error occurred while trying to create folder %s", qUtf8Printable(workdir));

Upvotes: 2

Jérôme
Jérôme

Reputation: 27027

When debbuging with qDebug, I find the following syntax much easier :

qDebug() << "An error occured while trying to create folder" << workdir;

To do this, you'll need to include the <QtDebug> header.

More info : Qt docs regarding qDebug().

Upvotes: 2

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84189

That should probably be:

qDebug("An error occured while trying to create folder %s", workdir.constData());

since qDebug takes const char* as first argument.

Upvotes: 5

Related Questions