LoginSignup
4
6

More than 5 years have passed since last update.

QDebug で引用符なしで文字列を出力する

Last updated at Posted at 2012-03-11

qDebug はコンソールに値を出力するのに便利な関数だが文字列だけ注意を要する。なぜならそのまま出力させると

const QString &s = "This is a test.";
qDebug() << s;

"This is a test"

と引用符付きで出力されてしまう。引用符なしで出力するには

const QString &s = "This is a test.";
qDebug("%s", qPrintable(s));

と qPrintable を使って printf 形式の引数で渡す必要がある。

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6