Using std::to_string

Hi

Can anyone suggest what's wrong here...

1
2
3
4
    int lettercount;
    lettercount=strlen("ABC");  
  
    subwin->doco->setPlainText(std::to_string(lettercount));


The second line here is failing to compile with error "/home/laurie/NetBeansProjects/QT_Learning2/QTDesigner/mainwindow.cpp:188: error: no matching function for call to 'QTextEdit::setPlainText(std::string)'
subwin->doco->setPlainText(std::to_string(lettercount));"

The second line works fine if I do something like

 
subwin->doco->setPlainText("10");


I'm sure I'm missing seomthing simple.

Cheers

Sam
^
Last edited on
I believe that setPlainText accepts either c-strings (char pointers) or QString and not std::string
Last edited on
which would mean that you need to use subwin->doco->setPlainText(std::to_string(lettercount).c_str());
Hi guys

It worked with
 
 subwin->doco->setPlainText(QString("You typed %1").arg(lettercount)))


Thanks for the pointers...

Sam
Topic archived. No new replies allowed.