本文整理汇总了C++中QByteArray::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::clear方法的具体用法?C++ QByteArray::clear怎么用?C++ QByteArray::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeSerial
void MainWindow::on_pid_yawn_i_2_valueChanged(double arg1)
{
output.clear();
output.append("SP2 2 "); //1. Pitc 2. Roll 3. Yaw //1. P 2. I 3.D
output.append(QString::number((float)arg1));
output.append("\r\n");
writeSerial(output);
}
示例2: str
/**
* Hashes the given string using the HMAC-SHA1 algorithm.
*
* http://stackoverflow.com/questions/3341167/how-to-implement-hmac-sha1-algorithm-in-qt/3594062#3594062
*
* \param key The string to be hashed
* \param secret The string that contains secret word
* \return The hashed string
*/
static QString hmac_sha1(const QString &key, const QString &secret)
{
int text_length; // Length of the text, that will be hashed
unsigned char* K; //For secret word.
int K_length; //Length of secret word
K_length = secret.size();
text_length = key.size();
//Need to do for XOR operation. Transforms QString to unsigned char
std::string tempString = secret.toStdString();
K = (unsigned char*)tempString.c_str();
unsigned char ipad[65]; // Inner pad
unsigned char opad[65]; // Outer pad
//unsigned char L[20]; //TODO if key > 64 bytes use this to obtain sha1 key
// Fills ipad and opad with zeros
memset( ipad, 0, sizeof ipad);
memset( opad, 0, sizeof opad);
// Copies Secret to ipad and opad
memcpy( ipad, K, K_length);
memcpy( opad, K, K_length);
// XOR operation for inner and outer pad
for (int i=0; i<64; i++) {
ipad[i] ^= 0x36;
opad[i] ^= 0x5c;
}
QByteArray context; // Stores hashed content
context.append((const char*) ipad,64); // Appends XOR:ed ipad to context
context.append(key); //Appends key to context
//Hashes Inner pad
QByteArray Sha1 = QCryptographicHash::hash(context,
QCryptographicHash::Sha1);
context.clear();
context.append((const char*) opad,64); //Appends opad to context
context.append(Sha1); //Appends hashed inner pad to context
Sha1.clear();
// Hashes outerpad
Sha1 = QCryptographicHash::hash(context, QCryptographicHash::Sha1);
// String to return hashed stuff in Base64 format
QByteArray str(Sha1.toBase64());
return str;
}
示例3: setupArtNetPollReply
void ArtNetPacketizer::setupArtNetPollReply(QByteArray &data, QHostAddress ipAddr, QString MACaddr)
{
int i = 0;
data.clear();
data.append(m_commonHeader);
data.remove(9, 2);
const char opCodeMSB = (ARTNET_POLLREPLY >> 8);
data[9] = opCodeMSB;
QString ipStr = ipAddr.toString();
QStringList ipAddrList = ipStr.split(".");
foreach (QString val, ipAddrList)
data.append((char)val.toInt()); // IP address[4]
data.append((char)0x36); // Port LSB
data.append((char)0x19); // Port MSB
data.append((char)0x04); // Version MSB
data.append((char)0x20); // Version LSB
data.append((char)0x00); // Sub Switch MSB
data.append((char)0x00); // Sub Switch LSB
data.append((char)0xFF); // OEM Value MSB
data.append((char)0xFF); // OEM Value LSB
data.append((char)0x00); // UBEA version
data.append((char)0xF0); // Status1 - Ready and booted
data.append((char)0xFF); // ESTA Manufacturer MSB
data.append((char)0xFF); // ESTA Manufacturer LSB
data.append("QLC+"); // Short Name
for (i = 0; i < 14; i++)
data.append((char)0x00); // 14 bytes of stuffing
data.resize(data.length() + 14);
data.append("Q Light Controller Plus - ArtNet interface"); // Long Name
for (i = 0; i < 22; i++) // 64-42 bytes of stuffing. 42 is the lenght of the long name
data.append((char)0x00);
for (i = 0; i < 64; i++)
data.append((char)0x00); // Node report
data.append((char)0x00); // NumPort MSB
// FIXME: this should reflect the actual state of QLC+ output ports !
data.append((char)0x01); // NumPort LSB
data.append((char)0x80); // Port 1 type: can output DMX512 data
data.append((char)0x80); // Port 2 type: can output DMX512 data
data.append((char)0x80); // Port 3 type: can output DMX512 data
data.append((char)0x80); // Port 4 type: can output DMX512 data
// FIXME: this should reflect the actual state of QLC+ output ports !
for (i = 0; i < 12; i++)
data.append((char)0x00); // Set GoodInput[4], GoodOutput[4] and SwIn[4] all to unknown state
data.append((char)0x00); // SwOut0 - output 0
data.append((char)0x01); // SwOut1 - output 1
data.append((char)0x02); // SwOut2 - output 2
data.append((char)0x03); // SwOut3 - output 3
for (i = 0; i < 7; i++)
data.append((char)0x00); // SwVideo, SwMacro, SwRemote and 4 spare bytes
QStringList MAC = MACaddr.split(":");
foreach (QString couple, MAC)
{
bool ok;
data.append((char)couple.toInt(&ok, 16));
}
示例4: gdbQuoteTypes
QByteArray gdbQuoteTypes(const QByteArray &type)
{
// gdb does not understand sizeof(Core::IDocument*).
// "sizeof('Core::IDocument*')" is also not acceptable,
// it needs to be "sizeof('Core::IDocument'*)"
//
// We never will have a perfect solution here (even if we had a full blown
// C++ parser as we do not have information on what is a type and what is
// a variable name. So "a<b>::c" could either be two comparisons of values
// 'a', 'b' and '::c', or a nested type 'c' in a template 'a<b>'. We
// assume here it is the latter.
//return type;
// (*('myns::QPointer<myns::QObject>*'*)0x684060)" is not acceptable
// (*('myns::QPointer<myns::QObject>'**)0x684060)" is acceptable
if (isPointerType(type))
return gdbQuoteTypes(stripPointerType(type)) + '*';
QByteArray accu;
QByteArray result;
int templateLevel = 0;
const char colon = ':';
const char singleQuote = '\'';
const char lessThan = '<';
const char greaterThan = '>';
for (int i = 0; i != type.size(); ++i) {
const char c = type.at(i);
if (isLetterOrNumber(c) || c == '_' || c == colon || c == ' ') {
accu += c;
} else if (c == lessThan) {
++templateLevel;
accu += c;
} else if (c == greaterThan) {
--templateLevel;
accu += c;
} else if (templateLevel > 0) {
accu += c;
} else {
if (accu.contains(colon) || accu.contains(lessThan))
result += singleQuote + accu + singleQuote;
else
result += accu;
accu.clear();
result += c;
}
}
if (accu.contains(colon) || accu.contains(lessThan))
result += singleQuote + accu + singleQuote;
else
result += accu;
//qDebug() << "GDB_QUOTING" << type << " TO " << result;
return result;
}
示例5: d
qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
{
QByteArray message;
while (true) {
while (!stack.empty() && (data.empty() || stack.top() <= data.front().start)) {
if (stack.top() > until) {
qint64 memory_next = appendMemoryEvents(until, messages);
return memory_next == -1 ? stack.top() : qMin(stack.top(), memory_next);
}
appendMemoryEvents(stack.top(), messages);
QQmlDebugStream d(&message, QIODevice::WriteOnly);
d << stack.pop() << RangeEnd << Javascript;
messages.append(message);
}
while (!data.empty() && (stack.empty() || data.front().start < stack.top())) {
const QV4::Profiling::FunctionCallProperties &props = data.front();
if (props.start > until) {
qint64 memory_next = appendMemoryEvents(until, messages);
return memory_next == -1 ? props.start : qMin(props.start, memory_next);
}
appendMemoryEvents(props.start, messages);
QQmlDebugStream d_start(&message, QIODevice::WriteOnly);
d_start << props.start << RangeStart << Javascript;
messages.push_back(message);
message.clear();
QQmlDebugStream d_location(&message, QIODevice::WriteOnly);
d_location << props.start << RangeLocation << Javascript << props.file << props.line
<< props.column;
messages.push_back(message);
message.clear();
QQmlDebugStream d_data(&message, QIODevice::WriteOnly);
d_data << props.start << RangeData << Javascript << props.name;
messages.push_back(message);
message.clear();
stack.push(props.end);
data.pop_front();
}
if (stack.empty() && data.empty())
return appendMemoryEvents(until, messages);
}
}
示例6: setProfile
void WifiAPItem::setProfile(WifiProfile & profile)
{
if (!(profile_ == profile))
{
profile_ = profile;
updateByProfile(profile_);
}
selected_item_ = 0;
previous_selected_item_ = 0;
selected_bssid.clear();
}
示例7: checkLinkStatus
// ------------------------------------------------------------------------ //
void RunModule::checkLinkStatus()
{
if(dbg()) msg()("Checking link status...","RunModule::checkLinkStatus");
bool ok;
QByteArray datagram;
// send call to vmmapp port
int send_to_port = config().commSettings().vmmapp_port;
// header
QString cmd = "BBAAFFFF";
QString msbCounter = "0x80000000";
for(const auto& ip : socket().ipList()) {
datagram.clear();
QDataStream out (&datagram, QIODevice::WriteOnly);
out.device()->seek(0); //rewind
socket().updateCommandCounter();
////////////////////////////
// header
////////////////////////////
out << (quint32)(socket().commandCounter() + msbCounter.toUInt(&ok,16)) //[0,3]
<< (quint32) config().getHDMIChannelMap() //[4,7]
<< (quint32) cmd.toUInt(&ok,16); //[8,11]
////////////////////////////
// command
////////////////////////////
out << (quint32) 0 //[12,15]
<< (quint32) 16; //[16,19]
socket().SendDatagram(datagram, ip, send_to_port, "fec",
"RunModule::checkLinkStatus");
bool readOK = true;
readOK = socket().waitForReadyRead("fec");
if(readOK) {
emit checkLinks();
//if(dbg()) msg()("Processing replies...","RunModule::checkLinkStatus");
//socket().processReply("fec", ip);
} else {
msg()("Timeout while waiting for replies from VMM",
"RunModule::checkLinkStatus", true);
socket().closeAndDisconnect("fec", "RunModule::checkLinkStatus");
exit(1);
}
} // ip
socket().closeAndDisconnect("fec", "RunModule::checkLinkStatus");
}
示例8: configTP
// ------------------------------------------------------------------------ //
void RunModule::configTP(int tpskew, int tpwidth, int tppolarity)
{
if(dbg()) msg()("Configuring the pulser...","RunModule::configTP");
bool ok;
QByteArray datagram;
// send call to s6 port
int send_to_port = config().commSettings().s6_port;
QString cmd, msbCounter;
cmd = "AAAAFFFF";
msbCounter = "0x80000000";
for(const auto& ip : socket().ipList()) {
datagram.clear();
QDataStream out (&datagram, QIODevice::WriteOnly);
out.device()->seek(0); //rewind
socket().updateCommandCounter();
////////////////////////////
// header
////////////////////////////
out << (quint32)(socket().commandCounter() + msbCounter.toUInt(&ok,16)) //[0,3]
<< (quint32) config().getHDMIChannelMap() //[4,7]
<< (quint32) cmd.toUInt(&ok,16); //[8,11]
////////////////////////////
// command
////////////////////////////
out << (quint32) 0 //[12,15]
<< (quint32) 2 //[16,19]
<< (quint32) (tpskew + (tpwidth*16) + (tppolarity*128)); //[20,23]
socket().SendDatagram(datagram, ip, send_to_port, "fec",
"RunModule::configTP");
bool readOK = true;
readOK = socket().waitForReadyRead("fec");
if(readOK) {
if(dbg()) msg()("Processing replies...","RunModule::configTP");
socket().processReply("fec",ip);
} else {
msg()("Timeout while waiting for replies from VMM",
"RunModule::configTP", true);
socket().closeAndDisconnect("fec","RunModule::configTP");
exit(1);
}
} // ip
socket().closeAndDisconnect("fec","RunModule::configTP");
}
示例9: getGarbagePacket
//Заполнить пакет нулями
//Размер цифрового моноаудиофайла измеряется по формуле: A = D*T*i,
QByteArray JitterBuffer::getGarbagePacket()
{
QByteArray retBA;
retBA.clear();
int a = SAMPLING_FREQUENCY * packetSize_ / 1000 * BIT_REGISTER / 8;
for (int i = 0; i < a; i++) retBA.append('0');
return retBA;
}
示例10: taskResult
// sends the result of the task to the client
void Client::taskResult(Request *response){
if((response->getCode() == 1) && (response->getSuccess()))
username = response->getSender()->getName();
QByteArray buffer;
buffer.clear();
buffer.append(response->toQString());
socket->write(buffer);
socket->flush();
}
示例11: serializeImages
void TreeItemProtocol::serializeImages(const types::Images & src, QByteArray & dest)
{
dest.clear();
QDataStream stream(&dest, QIODevice::WriteOnly);
foreach (const QString & imageurl, src) {
stream << imageurl;
}
//dest = qCompress(dest);
}
示例12: serializeProposals
void TreeItemProtocol::serializeProposals(const types::Proposals & src, QByteArray & dest)
{
dest.clear();
QDataStream stream(&dest, QIODevice::WriteOnly);
foreach (const k::Proposal & p, src) {
stream << p.id << p.text;
}
//dest = qCompress(dest);
}
示例13: serializeProperties
void TreeItemProtocol::serializeProperties(const types::Properties & src, QByteArray & dest)
{
dest.clear();
QDataStream stream(&dest, QIODevice::WriteOnly);
foreach (const k::Property & p, src) {
stream << p.key << p.value << p.description;
}
//dest = dest);
}
示例14: run
void threadCercle::run()
{
QByteArray baReception;
sockClient.connectToHost(m_IPServeur, 55415);
int posX, posY, rayon;
m_bEtat=true;
if (sockClient.waitForConnected(5000))
{
emit(siConnecte("Cliquez!"));
while (m_bEtat)
{
sockClient.waitForReadyRead(100);
if(sockClient.bytesAvailable() > 0)
{
baReception.append(sockClient.read(sockClient.bytesAvailable()));
}
else
{
m_bEtat = false;
}
if(baReception[0] ==1)
{
posX = (baReception[1] << 8) + uchar(baReception[2]);
posY = (baReception[3] << 8) + uchar(baReception[4]);
rayon= uchar(baReception[5]);
emit (siNouvCercle(posX,posY,rayon));
}
else
{
if(baReception[0]==2)
{
emit(siConnecte("Vous gagnez!"));
}
else
{
if(baReception[0]==3)
{
emit(siConnecte("Vous avez perdu..."));
}
}
}
baReception.clear();
sockClient.write("#");
}
emit(siConnecte("Fin."));
}
else
{
emit(siConnecte("Une erreur s'est produite."));
}
sockClient.disconnectFromHost();
sockClient.close();
}
示例15: fillArray
void BinTreeNodeReader::fillArray(QByteArray& buffer, quint32 len, QDataStream &in)
{
buffer.clear();
for (quint32 count=0; count < len; count ++)
{
quint8 byte;
in >> byte;
buffer.append(byte);
}
}