การเชื่อมต่อ string เป็นเรื่องยากสำหรับผมมาก เพราะว่าหาตัวอย่างยังไงก็หาไม่เจอ
จริงๆแล้วมันไม่ได้ยากหรอก แต่เราใช้คำในการค้นหา ไม่ตรงกับความต้องการ(อีกแล้ว)
การเพิ่มข้อมูล string หรือการต่อข้อมูล string (Append string) สามารถทำได้ดังนี้
#include <QDebug>
#include <QString>
.
.
.
QString your_name = "Niran";
QString message = "Your name is " + your_name;
qDebug() << message;
หรือ
QString message = "Your name is ";
message += your_name;
qDebug() << message;
หรือ
QString message = "Your name is ";
message.append(your_name);
qDebug() << message;
ที่มา
http://www.qtcentre.org/threads/33603-how-to-concatenate-a-variable-with-a-string
ไม่มีความคิดเห็น:
แสดงความคิดเห็น