本文整理汇总了C++中QByteArray::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::push_back方法的具体用法?C++ QByteArray::push_back怎么用?C++ QByteArray::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toByteArray
QByteArray OpusHead::toByteArray() const
{
QByteArray data;
// Magic signature
data += QByteArray("OpusHead", 8);
// Version
data.push_back(static_cast<char>(0x01));
// Channel count
data.push_back(static_cast<char>(channelCount_));
// Pre-skip
size_t pos = data.size();
data.resize(data.size() + sizeof(preSkip_));
qToLittleEndian(preSkip_, reinterpret_cast<uchar*>(data.data()) + pos);
// Input sample rate
pos = data.size();
data.resize(data.size() + sizeof(inputSampleRate_));
qToLittleEndian(inputSampleRate_, reinterpret_cast<uchar*>(data.data()) + pos);
// Output gain
pos = data.size();
data.resize(data.size() + sizeof(outputGain_));
qToLittleEndian(outputGain_, reinterpret_cast<uchar*>(data.data()) + pos);
// Channel mapping family
data.push_back(static_cast<char>(0));
return data;
}
示例2: saveFile
void FileController::saveFile(QString src, QString line) {
if(path.isEmpty()) {
saveDialogEnable();
}
else {
QFile file(path);
file.open(QIODevice::ReadWrite);
QByteArray srcBytes;
QByteArray lineBytes;
string lineStd = line.toStdString();
for(int i = 0; i < lineStd.size(); ++i) {
lineBytes.push_back(lineStd[i]);
}
string srcStd = src.toStdString();
for(int i = 0; i < srcStd.size(); ++i) {
srcBytes.push_back(srcStd[i]);
}
file.resize(0);
file.write(lineBytes);
file.write("\n");
file.write(srcBytes);
}
}
示例3: saveToFile
void MutableMap::saveToFile(QString filename) {
int count=0;
char cur_data=0;
unsigned char d_mask=0x80;
QByteArray binblob = QByteArray();
const char hdr[16] = {'M','A','P',0x00,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
for(unsigned i=0; i<16; i++) {
binblob.push_back(hdr[i]);
}
while(count < data.size()) {
d_mask=0x80;
cur_data=0x00;
while(d_mask>=0x01) {
if(data.at(count))
cur_data |= d_mask;
d_mask >>= 1;
count++;
}
binblob.push_back(cur_data);
}
QFile mf(filename);
if(mf.open(QIODevice::WriteOnly)) {
mf.write(binblob);
}
}
示例4:
QByteArray CBNLSProtocol :: SEND_BNLS_NULL( )
{
QByteArray packet;
packet.push_back( (char)0 ); // packet length will be assigned later
packet.push_back( (char)0 ); // packet length will be assigned later
packet.push_back( BNLS_NULL ); // BNLS_NULL
AssignLength( packet );
return packet;
}
示例5: DumpTest
void DumpTest()
{
QByteArray arr;
arr.push_back(1);
arr.push_back(0x10);
arr.push_back(0x1f);
std::cout << PcUtils::DumpQByteArray(arr) << std::endl;
}
示例6: convName
static QByteArray convName(const QString& name) {
// Strip unicode & get rid of quotes, brackets.
QByteArray b;
for (QChar c : name) {
if (c <= 127 && c != QChar('"') && c != QChar('[') && c != QChar(']')) {
b.push_back(c.toLatin1());
} else {
b.push_back('?');
}
}
return b;
}
示例7: GetPixelData
QByteArray GetPixelData(const QImage& img) {
QByteArray result;
for (int i = 0; i < img.width(); i++) {
for (int j = 0; j < img.height(); j++) {
QRgb c = img.pixel(i, j);
result.push_back(qRed(c));
result.push_back(qGreen(c));
result.push_back(qBlue(c));
}
}
return result;
}
示例8: sendData
void EasyTransferPi::sendData(uint8_t *dataPtr, uint8_t lenght)
{
uint8_t CS=lenght;
QByteArray dataArray;
dataArray.push_back(0x06);
dataArray.push_back(0x85);
dataArray.push_back(lenght);
for (int i = 0; i < lenght; ++i) {
dataArray.push_back(dataPtr[i]);
CS^=*(dataPtr+i);
}
dataArray.push_back(CS);
portManager->writeData(dataArray);
}
示例9: updateLEDs
void msl::updateLEDs()
{
qDebug() << "Updating LEDs!";
QByteArray array;
array.push_back(SET_COLOR);
array.push_back(DIRECT_LED);
array.push_back((char)this->ui.verticalSlider_uv->value());
array.push_back((char)this->ui.verticalSlider_white->value());
array.push_back(this->colorDialog->currentColor().red());
array.push_back(this->colorDialog->currentColor().green());
array.push_back(this->colorDialog->currentColor().blue());
unsigned char checksum=0;
for(QByteArray::iterator it = array.begin(); it != array.end(); ++it)
{
checksum^=*it;
}
array.push_back(checksum);
//Start with AA 55
array.push_front(0x55);
array.push_front(0xAA);
emit sendArray(array);
}
示例10: GetQByteArray
QByteArray CGameSlot :: GetQByteArray( ) const
{
QByteArray b;
b.push_back( m_PID );
b.push_back( m_DownloadStatus );
b.push_back( m_SlotStatus );
b.push_back( m_Computer );
b.push_back( m_Team );
b.push_back( m_Colour );
b.push_back( m_Race );
b.push_back( m_ComputerType );
b.push_back( m_Handicap );
return b;
}
示例11: return
const QByteArray &Mnist::getImage(int index)
{
if (images.contains(index)) {
return images[index];
}
QByteArray rawImage = rawImages[index];
QByteArray image;
// for (int i = 0; i < nbRows; i ++) {
// for (int j = 0; j < nbCols; j++) {
// cout << ("00"+QString::number((int) (quint8)rawImage[i*nbCols+j])).right(3).toStdString() << "|";
// }
// cout << endl;
// }
for (int i = 0; i < nbRows; i += 4) {
for (int j = 0; j < nbCols; j += 4) {
int finalValue = 0;
auto reducePixel = [&](int i, int j) {
return (quint8(rawImage[i*nbCols+j]) + quint8(rawImage[(i+1)*nbCols+j]) + quint8(rawImage[i*nbCols+(j+1)]) + quint8(rawImage[(i+1)*nbCols+(j+1)]))/4;
};
int val;
val = reducePixel(i, j);
finalValue+= val >= 120;
finalValue+= val > 160;
finalValue *= 3;
val = reducePixel(i, j+2);
finalValue+= val >= 120;
finalValue+= val > 160;
finalValue *= 3;
val = reducePixel(i+2, j);
finalValue+= val >= 120;
finalValue+= val > 160;
finalValue *= 3;
val = reducePixel(i+2, j+2);
finalValue+= val >= 120;
finalValue+= val > 160;
image.push_back(finalValue);
}
}
// QList<int> values;
// for (int i = 0; i < image.size(); i++) {
// values.push_back(i*81+image[i]);
// }
// MnistGraphics graphics;
// graphics.run(QList<QVector<int>>() << values.toVector());
images[index] = image;
return images[index];
}
示例12:
void CRC32::TestAgainRaw()
{
QByteArray data;
for(int i = 0; i < 32; ++i) data.push_back(i);
Platform::dword rawCrc = Utils::UpdateCRC32(data.data(), data.size());
Platform::dword boostCrc = Utils::CRC32(data).checksum();
TUT_ASSERT(rawCrc == boostCrc);
}
示例13: sendTestData
void OsiTransportTest::sendTestData(CConnection* that)
{
QByteArray qdata;
qdata.reserve(sizeof(testData)/sizeof(testData[0]));
for (char c: testData)
{
qdata.push_back(c);
}
that->send(qdata, (quint32)0, qdata.size());
}
示例14: createEnglishAscii
void ExportAsciiDialog::createEnglishAscii(){
QFont f("Consolas,Courier,monospace", 8);
m_ui->asciiTextEdit->setFont(f);
QByteArray s;
s.reserve(boardBuffer.size() + 2 * boardBuffer[0].size() * 3);
s.append(" ");
for (int i=0; i<boardBuffer[0].size(); ++i){
s.push_back(' ');
s.push_back( 'A' + (i > 7 ? i+1 : i) );
}
s.push_back('\n');
for (int y=0; y<boardBuffer.size(); ++y){
s.append( QString("%1").arg(boardBuffer.size() - y, 2) );
for (int x=0; x<boardBuffer[y].size(); ++x){
if (boardBuffer[y][x].black())
s.append(" #");
else if (boardBuffer[y][x].white())
s.append(" O");
else if (isStar(x, y))
s.append(" +");
else
s.append(" .");
}
s.append( QString(" %1\n").arg(boardBuffer.size() - y, 2) );
}
s.append(" ");
for (int i=0; i<boardBuffer[0].size(); ++i){
s.push_back(' ');
s.push_back( 'A' + (i > 7 ? i+1 : i) );
}
m_ui->asciiTextEdit->setPlainText(s);
}
示例15: SendData
void UdpChannel::SendData(std::vector<Platform::byte> const &data)
{
QByteArray dataArray;
for (int i = 0; i < data.size(); ++i)
{
dataArray.push_back(data[i]);
}
boost::shared_ptr<iNet::SocketData> socketData(
new iNet::SocketData(m_remouteInf.getAddress(), m_cfg.localPotr(), dataArray));
m_socket->SendData(socketData);
}