1

Here is a simple domo:

string strList[4] = {"Blue", "Red", "Yellow"};
qDebug()<<"strList element : "<<strList[1];

error: C2678: binary '<<': no operator found which takes a left-hand operand of type 'QDebug' (or there is no acceptable conversion)

What is the problem for string display?

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
jwm
  • 4,832
  • 10
  • 46
  • 78

2 Answers2

2

The "string" class isn't recognized by Qt's Debug module. You need to be using QString and in this case, you probably want QStringList (which is equivalent to QList ).

QStringList strList;
strList << "Blue" << "Red" << "Yellow";
qDebug() << "strList element : " << strList[1];
goug
  • 2,294
  • 1
  • 11
  • 15
1

qDebug doesnt take strings but can handle very good the "c- strings"

instead of doing:

qDebug()<<"strList element : "<<strList[1];

do:

string strList[4] = {"Blue", "Red", "Yellow"};
qDebug()<<"strList element : "<<strList[1].c_str();
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97