2

I have a QStringlist "word" and a Qstring "a" which is one element of word. I want to insert "a" as a label for QPieSlice but I got the following error. Any idea? error: No viable conversion from 'QCharRef' to 'QString' How can I convert QCharRef to QString?

//...
   QStringList word;
   for (int i = 0; i < NUM1; i++) {
        word.append(jsonArray[i].toString());
    }
//...
   QString a = word[0];
   qDebug() << typeid(word[0]). name(); // Answer: 7QString
//...   
   SLICE = new QPieSlice(a, NUM2); // error: No viable conversion from 'QCharRef' to 'QString' 

When I replace it with:

QString a = QString(word[0]);

it runs without error but no output just this massage:

Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt

mahya
  • 51
  • 4

0 Answers0