how to set ' " ' in QString
-
Hi All,
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! -
Hi All,
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.
-
@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.
@jsulm
It will give me this error when I compile.error: 'cout' is not a member of 'std' std::cout << command; ^ -
@jsulm
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:#include <iostream> -
@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:#include <iostream>@jsulm
Thanks I had read the document and it work great! -
@jsulm
It will give me this error when I compile.error: 'cout' is not a member of 'std' std::cout << command; ^ -
or
qDebug().noquote() << command; -
To added to @jsulm, you can use
qPrintable()instead ofstd::cout.like this:
qDebug() << qPrintable(command);or
qDebug() << command.toLocal8Bit().constData();@Devopia53
Thanks! I think this is more familiar to me. -
or
qDebug().noquote() << command;@Chris-Kawa
Thanks for the reply.
I can do this too!