本文整理汇总了C++中QBitArray::at方法的典型用法代码示例。如果您正苦于以下问题:C++ QBitArray::at方法的具体用法?C++ QBitArray::at怎么用?C++ QBitArray::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBitArray
的用法示例。
在下文中一共展示了QBitArray::at方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Number
Number(const QBitArray &bitArray)
{
bits = bitArray.size();
value = 0;
for (quint8 i=0; i<bits; i++)
if (bitArray.at(i)) value += 1 << (bits-i-1);
}
示例2: computeValue
//! Compute hidden value according to stegotable
bool StegoTable::computeValue(float miv, bool next)
{
QBitArray stegoTable = next ? getNextTable() : _stTables[_indexTable[_currentTable]];
int index = floor(miv / (double)_k);
/*m_logger->debug("miv: " + QString::number(miv)
+ "=> stegotable index: " + QString::number(index));*/
return stegoTable.at(index);
}
示例3: write
QString BaseStateAbstract::write(QBitArray barray)
{
QString ret;
for (int i = 0; i < barray.size(); i++) {
if (barray.at(i))
ret.append(B_ONE);
else
ret.append(B_ZERO);
}
return ret;
}
示例4: compress
static QBitArray compress(const QBitArray &data, const Number &before, const Number &after)
{
const int bits = before.bits;
Number beforeSize(before.bits, 5);
Number afterSize(after.bits, 5);
QBitArray result(data.size() + beforeSize.bits + before.bits);
quint64 resultIndex = 0;
for (quint8 i=0; i<beforeSize.bits; i++) result.setBit(resultIndex + i, beforeSize[i]);
resultIndex += beforeSize.bits;
for (quint8 i=0; i<before.bits; i++) result.setBit(resultIndex + i, before[i]);
resultIndex += before.bits;
for (quint8 i=0; i<afterSize.bits; i++) result.setBit(resultIndex + i, afterSize[i]);
resultIndex += afterSize.bits;
for (quint8 i=0; i<after.bits; i++) result.setBit(resultIndex + i, after[i]);
resultIndex += after.bits;
Number index(0, bits);
for (quint8 i=0; i<bits-1; i++)
index << data.at(i);
quint64 i = 0;
while (i < data.size()-bits) {
index << data.at(i + bits - 1);
if (index == before) {
for (quint8 j=0; j<after.bits; j++) result.setBit(resultIndex+j, after[j]);
resultIndex += after.bits;
i += before.bits;
} else {
result.setBit(resultIndex++, data.at(i++));
}
}
while (i < data.size())
result.setBit(resultIndex++, data.at(i++));
result.resize(resultIndex);
return result;
}
示例5: count
static void count(const QBitArray &data, quint8 bits, Count &most, Count &least)
{
Number index(0, bits);
for (quint8 i=0; i<bits-1; i++)
index << data.at(i);
const quint64 size = quint64(1) << bits;
quint8 *counts = new quint8[size];
memset(counts, 0, size);
for (quint64 i=0; i<data.size()-bits; i++) {
index << data.at(i + bits - 1);
if (counts[index] < 255) counts[index]++;
}
most = Count(Number(), 0);
least = Count(Number(), 255);
for (quint64 i=0; i<size; i++) {
if (counts[i] > most.count) most = Count(Number(i, bits), counts[i]);
if (counts[i] < least.count) least = Count(Number(i, bits), counts[i]);
}
delete[] counts;
}
示例6: slot_test
void QtBinaryCalc::slot_test()
{
QBitArray *a = new QBitArray();
QBitArray *b = new QBitArray();
QBitArray *result = new QBitArray();
QString *resultString = new QString();
a->fill(0, 16);
b->fill(0, 16);
result->fill(0, 16);
for(int i = 0 ; i < this->numberA->getBytesAsBin().count() ; i++)
{
a->setBit(i, this->numberA->getBytesAsBin().at(i).digitValue() );
}
for(int i = 0 ; i < this->numberB->getBytesAsBin().count() ; i++)
{
b->setBit(i, this->numberB->getBytesAsBin().at(i).digitValue() );
}
*result = ~(*a);
SHOWVALUE(result, *result);
for ( int i = result->count()-1 ; i >= 0 ; i-- )
{
resultString->append( QString::number( (int)result->at(i) ) );
}
SHOWVALUE(resultString, *resultString);
SHOWVALUE(resultString->toInt(0, 2), resultString->toInt(0,2));//tu trzeba zrobic invert bitow 0->16, 1->15 itd
this->numberResult->slot_setValue(resultString->toInt());
SHOWVALUE(a, *a);
SHOWVALUE(b, *b);
}
示例7: switch
void MainWindow::on_answerButton_2_clicked()
{
ui->answerButton_2->hide();
QList<QString> userAnswers;
Question &q = quiz->currentQuestion();
switch(q.getQuestionType())
{
case(Question::NOUN) :
userAnswers.append(ui->answerBox_1->text());
userAnswers.append(ui->answerBox_2->text());
userAnswers.append(ui->answerBox_3->text());
userAnswers.append(ui->answerBox_4->text());
userAnswers.append(ui->answerBox_5->text());
break;
case(Question::VERB) :
userAnswers.append(ui->answerBox_1->text());
userAnswers.append(ui->answerBox_2->text());
userAnswers.append(ui->answerBox_3->text());
userAnswers.append(ui->answerBox_4->text());
userAnswers.append(ui->answerBox_5->text());
break;
case(Question::ADJECTIVE) :
userAnswers.append(ui->answerBox_1->text());
userAnswers.append(ui->answerBox_2->text());
userAnswers.append(ui->answerBox_3->text());
break;
}
q.setUserAnswers(userAnswers);
QBitArray validAnswers = q.validAnswers();
switch(q.getQuestionType())
{
case(Question::NOUN) :
if (validAnswers.at(0)) {
ui->feedback_1->setText("Correct!");
} else {
ui->feedback_1->setText("Wrong! it is " + q.getAnswers().at(0));
}
if (validAnswers.at(1)) {
ui->feedback_2->setText("Correct!");
} else {
ui->feedback_2->setText("Wrong! it is " + q.getAnswers().at(1));
}
if (validAnswers.at(2)) {
ui->feedback_3->setText("Correct!");
} else {
ui->feedback_3->setText("Wrong! it is " + q.getAnswers().at(2));
}
if (validAnswers.at(3)) {
ui->feedback_4->setText("Correct!");
} else {
ui->feedback_4->setText("Wrong! it is " + q.getAnswers().at(3));
}
if (validAnswers.at(4)) {
ui->feedback_5->setText("Correct!");
} else {
ui->feedback_5->setText("Wrong! it is " + q.getAnswers().at(4));
}
break;
case(Question::VERB) :
if (validAnswers.at(0)) {
ui->feedback_1->setText("Correct!");
} else {
ui->feedback_1->setText("Wrong! it is " + q.getAnswers().at(0));
}
if (validAnswers.at(1)) {
ui->feedback_2->setText("Correct!");
} else {
ui->feedback_2->setText("Wrong! it is " + q.getAnswers().at(1));
}
if (validAnswers.at(2)) {
ui->feedback_3->setText("Correct!");
} else {
ui->feedback_3->setText("Wrong! it is " + q.getAnswers().at(2));
}
if (validAnswers.at(3)) {
ui->feedback_4->setText("Correct!");
} else {
ui->feedback_4->setText("Wrong! it is " + q.getAnswers().at(3));
}
if (validAnswers.at(4)) {
ui->feedback_5->setText("Correct!");
} else {
ui->feedback_5->setText("Wrong! it is " + q.getAnswers().at(4));
}
break;
case(Question::ADJECTIVE) :
if (validAnswers.at(0)) {
ui->feedback_1->setText("Correct!");
} else {
ui->feedback_1->setText("Wrong! it is " + q.getAnswers().at(0));
}
if (validAnswers.at(1)) {
ui->feedback_2->setText("Correct!");
} else {
ui->feedback_2->setText("Wrong! it is " + q.getAnswers().at(1));
//.........这里部分代码省略.........
示例8: slot_operatorChanged
//FUNKCJA ODPOWIADA ZA AKTUALIZOWANIE WYNIKU PO ZMIANIE OPERATORA PO LEWEJ STRONIE i za zmiane pol w numberA lub B.
//Dokladniejszy opis w kilkulinijkowym komentarzu pod koniec konstruktora QtBinaryCalc
void QtBinaryCalc::slot_operatorChanged(int op)
{
//int op - identyfikator operatora bitowego (1-NOT, 2-AND itd)
/////////////////////////////////////////////////////////
QBitArray a;
QBitArray b;
QBitArray result;
QString resultString;
a.fill(0, 16);
b.fill(0, 16);
result.fill(0, 16);
for(int i = 0 ; i < this->numberA->getBytesAsBin().count() ; i++)
{
a.setBit(i, this->numberA->getBytesAsBin().at(i).digitValue() );
}
for(int i = 0 ; i < this->numberB->getBytesAsBin().count() ; i++)
{
b.setBit(i, this->numberB->getBytesAsBin().at(i).digitValue() );
}
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
if(op == -1)
{
op = chooser->getOperator();
}
if (op == 1)
{
result = ~(a);
}
else
if (op == 2)
{
result = a&b;
}
else
if (op == 3)
{
result = a|b;
}
else
if (op == 4)
{
result = a^b;
}
QString resultQString;
// SHOWLINE();
for(int i = 0 ; i <= 15 ; i++)
{
SHOWONLYVALUE((int)result.at(i));
resultQString.append( QString::number(result.at(i)) );
}
this->numberResult->slot_setValue( resultQString.toInt(0, 2) );
}