本文整理汇总了C++中QBitArray::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ QBitArray::fill方法的具体用法?C++ QBitArray::fill怎么用?C++ QBitArray::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBitArray
的用法示例。
在下文中一共展示了QBitArray::fill方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCOMPARE
void tst_QBitArray::countBits2()
{
QBitArray bitArray;
for (int i = 0; i < 4017; ++i) {
bitArray.resize(i);
bitArray.fill(true);
QCOMPARE(bitArray.count(true), i);
QCOMPARE(bitArray.count(false), 0);
bitArray.fill(false);
QCOMPARE(bitArray.count(true), 0);
QCOMPARE(bitArray.count(false), i);
}
}
示例2: fillMaskForRegion
void ImageOverlayRegionFinder::fillMaskForRegion(QBitArray &mask, const QRect ®ion)
{
for (int y = region.top(); y <= region.bottom(); y++)
{
int offset = y * m_overlay.getColumns();
mask.fill(true, offset + region.left(), offset + region.right() + 1);
}
}
示例3: 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);
}
示例4: getCheckedDays
void EventWinRecurrence::getCheckedDays(QBitArray &rDays) {
rDays.fill(FALSE);
if (mondayBox->isChecked())
rDays.setBit(0, 1);
if (tuesdayBox->isChecked())
rDays.setBit(1, 1);
if (wednesdayBox->isChecked())
rDays.setBit(2, 1);
if (thursdayBox->isChecked())
rDays.setBit(3, 1);
if (fridayBox->isChecked())
rDays.setBit(4, 1);
if (saturdayBox->isChecked())
rDays.setBit(5, 1);
if (sundayBox->isChecked())
rDays.setBit(6, 1);
}
示例5: 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) );
}
示例6: readScans
/// not threadsafe
i64 DataFile::readScans(std::vector<int16> & scans_out, u64 pos, u64 num2read, const QBitArray & channelSubset, unsigned downSampleFactor)
{
if (pos > scanCt) return -1;
if (num2read + pos > scanCt) num2read = scanCt - pos;
QBitArray chset = channelSubset;
if (chset.size() != (i64)nChans) chset.fill(true, nChans);
if (downSampleFactor <= 0) downSampleFactor = 1;
unsigned nChansOn = chset.count(true);
int sizeofscans;
if ( (num2read / downSampleFactor) * downSampleFactor < num2read )
sizeofscans = ((num2read / downSampleFactor)+1) * nChansOn;
else
sizeofscans = ((num2read / downSampleFactor)) * nChansOn;
scans_out.resize(sizeofscans);
u64 cur = pos;
i64 nout = 0;
std::vector<int> onChans;
onChans.reserve(chset.size());
for (int i = 0, n = chset.size(); i < n; ++i)
if (chset.testBit(i)) onChans.push_back(i);
qint64 maxBufSize = nChans*sRate*1; // read about max 1sec worth of data at a time as an optimization
qint64 desiredBufSize = num2read*nChans; // but first try and do the entire requested read at once in our buffer if it fits within our limits..
if (desiredBufSize > maxBufSize) desiredBufSize = maxBufSize;
std::vector<int16> buf(desiredBufSize);
if (int(buf.size()) < nChans) buf.resize(nChans); // minimum read is 1 scan
while (cur < pos + num2read) {
if (!dataFile.seek(cur * sizeof(int16) * nChans)) {
Error() << "Error seeking in dataFile::readScans()!";
scans_out.clear();
return -1;
}
qint64 nr = dataFile.read(reinterpret_cast<char *>(&buf[0]), sizeof(int16) * buf.size());
if (nr < int(sizeof(int16) * nChans)) {
Error() << "Short read in dataFile::readScans()!";
scans_out.clear();
return -1;
}
int nscans = int(nr/sizeof(int16))/nChans;
if (nscans <= 0) {
Error() << "Short read in dataFile::readScans()... nscans <= 0!";
scans_out.clear();
return -1;
}
const int16 *bufptr = &buf[0];
const int onChansSize = int(onChans.size());
const int skip = nChans*downSampleFactor;
for (int sc = 0; sc < nscans && cur < pos + num2read; /* .. */) {
if (int(nChansOn) == nChans) {
i64 i_out = nout * nChans;
for (int i = 0; i < nChans; ++i)
scans_out[i_out + i] = int16(bufptr[i]);
} else {
// not all chans on, put subset 1 by 1 in the output vector
i64 i_out = nout*i64(nChansOn);
for (int i = 0; i < onChansSize; ++i)
scans_out[i_out++] = int16(bufptr[onChans[i]]);
}
++nout;
bufptr += skip;
sc += downSampleFactor;
cur += downSampleFactor;
}
}
return nout;
}