本文整理汇总了C++中QByteArray::fromHex方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::fromHex方法的具体用法?C++ QByteArray::fromHex怎么用?C++ QByteArray::fromHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::fromHex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_pbSend_clicked
void Widget::on_pbSend_clicked()
{
if (netServer == NULL) return;
QByteArray ba = qPrintable(ui->pteSend->toPlainText());
ba = ba.replace("\n", "\r\n");
if (ui->chkSendHexa->checkState() == Qt::Checked) ba = ba.fromHex(ba);
netServer->write(ba);
}
示例2: on_butExchangeData_clicked
void widgetData::on_butExchangeData_clicked()
{
QByteArray dat = "data ";
QByteArray m = ui->editSend->text().toLocal8Bit();
QByteArray temp = m.fromHex(m);
//dat += m.number(m.fromHex(m).count()) +" " + m.fromHex(m);
dat += m.number(temp.count()) + " " + temp.toHex();
emit SendCom(dat);
}
示例3: send_ucp_pack
//
//void send_ucp_pack(uint8_t idx, uint16_t value)
//
void CComCalier::send_ucp_pack(uint8_t idx, uint16_t value)
{
if(Uart != NULL && Uart->isOpen())
{
QString tempQString;
tempQString = "55aa00";
tempQString += QString("%1").arg(idx,2,16,QLatin1Char('0'));
tempQString += QString("%1").arg((uint8_t)(value&0xff),2,16,QLatin1Char('0'));
tempQString += QString("%1").arg((uint8_t)(value>>8),2,16,QLatin1Char('0'));
tempQString += "0000";
QByteArray tempByteArray;
tempByteArray.append(tempQString);
Uart->write(tempByteArray.fromHex(tempByteArray));
}
示例4: load
bool CWizRtfReader::load(const QString& strFile, QString& strText)
{
QByteArray ba = file_load (strFile);
QString text;
text.reserve (ba.size());
int i = 0;
int l = ba.size();
QString ansicgp;
int n = ba.indexOf ("ansicpg");
if (n != -1)
{
int m = ba.indexOf ('\\', n);
n += 7;
ansicgp = ba.mid (n, m - n);
}
if (ansicgp.isEmpty()) //assuming unicode
{
while (i < l)
if ((ba.at(i) == '\\') && (ba.at(i + 1) == 'u'))
{
QByteArray ta = ba.mid (i, 7);
ta = ta.mid (2, 4);
QChar c (ta.toInt());
text.append (c);
i += 7 + 3;
}
else
{
text.append (ba.at(i));
i++;
}
}
else
{
ansicgp.prepend ("CP");
QTextCodec *codec = QTextCodec::codecForName (ansicgp.toUtf8().data());
qDebug() << "not unicode!";
while (i < l)
if ((ba.at(i) == '\\') && (ba.at(i + 1) == '\''))
{
QByteArray ta = ba.mid (i, 4);
ta = ta.mid (2, 2);
QByteArray bh = ta.fromHex (ta);
text.append (codec->toUnicode (bh));
i += 4;
}
else
{
text.append (ba.at(i));
i++;
}
}
strText = rtf_strip (text);
return true;
}