QString data to char*
1
2
3
const std::size_t count = data.size();
unsigned char* hex =new unsigned char[count];
std::memcpy(hex,data.constData(),count);
cs


char* to qstring


1
2
3
    y::t send_Data[15= {0xFF0xFE0x000xEE0,};
    QByteArray send_Data_Bytes = QByteArray::fromRawData((char*)send_Data, 15);
    port->write( send_Data_Bytes );
cs


QByteArray initialization with hex


1
2
QByteArray m_data = QByteArray("\x0c\x06\x04\x04\x02\x00",6);
emit sendByteArray(m_data);
cs


QString 문자열 만들기


1
2
3
4
5
6
7
8
9
 
void debugBytes(y::p bytes){
    QString msg;
 
    msg.sprintf("0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X",
                bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10]);
 
    qDebug() << msg << endl;
}
cs


char* 메세지 박스로 출력 


1
2
3
4
5
6
7
8
9
10
11
void showBytes(y::p bytes){
    QMessageBox box;
    QString msg;
 
    msg.sprintf("0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X",
                bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10]);
 
    box.setText(msg);
    box.exec();
 
}
cs


Qstring formating을 이용한 qDebug 출력


1
2
 qDebug() << QString("id : %1 direc : %2 degree : %3 vel : %4").arg(id).arg(direction).arg(degree).arg(vel) << endl;
 
cs





1
2
3
4
5
    for(z::t i(0) ; i < 11 ; ++i) {
 
        temp.sprintf("0x%02x ", yData[i]);
        msg += temp;
    }
cs







+ Recent posts