Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
how to set ' " ' in QString
victor wang last edited by victor wang
I'm using qt5.5 on my computer.
And I try to set a command like bellow.
/usr/sbin/wpa_cli -i wlan0 set_network psk '"iPhone"'
So I write this way in my program.
QString wifi = "iPhone"; QString command = "/usr/sbin/wpa_cli -i wlan0 set_network psk '\""+wifi+"\"'"; QString test ="hello"; qDebug()<<command;
But i will get the output like bellow.
/usr/sbin/wpa_cli -i wlan0 set_network psk '\"iPhone\"'
Is that ' \ ' have to put behind the ' " '?
Thanks in Advanced!
@victor-wang Just print out your string with
std::cout << command;
qDebug is for debugging and prints out the strings like you see them in the code.
It will give me this error when I compile.
error: 'cout' is not a member of 'std' std::cout << command; ^
@victor-wang Well, there is documentation you could read to solve the problem (note: cout is part of C++ standard library): http://en.cppreference.com/w/cpp/io/cout ...
You need to include <iostream> header file:
Thanks I had read the document and it work great!
Devopia53 last edited by
To added to @jsulm, you can use
qDebug() << qPrintable(command);
qDebug() << command.toLocal8Bit().constData();
qDebug().noquote() << command;
Thanks! I think this is more familiar to me.
Thanks for the reply.
I can do this too!