本文整理汇总了C++中QQueue::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QQueue::size方法的具体用法?C++ QQueue::size怎么用?C++ QQueue::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQueue
的用法示例。
在下文中一共展示了QQueue::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processBytes
void Telnet::processBytes(QByteArray bytes)
{
QQueue<uchar> buffer;
foreach (uchar c, bytes)
{
switch (_state)
{
case TOP_LEVEL:
handleStateTopLevel(c, &buffer);
break;
case SEENCR:
handleStateSeenCr(c, &buffer);
break;
case SEENIAC:
handleStateSeenIac(c);
break;
case SEENWILL:
handleStateSeenWill(c);
break;
case SEENWONT:
sendCommand(DONT, c);
_state = TOP_LEVEL;
break;
case SEENDO:
handleStateSeenDo(c);
break;
case SEENDONT:
sendCommand(WONT, c);
_state = TOP_LEVEL;
break;
case SEENSB:
_sbOption = c;
_sbBuffer->clear();
_state = SUBNEGOT;
break;
case SUBNEGOT:
if (c == IAC)
_state = SUBNEG_IAC;
else
_sbBuffer->append(c);
break;
case SUBNEG_IAC:
handleStateSubNegIac(c);
break;
default:
break;
}
}
int chunk_sz = 256;
while (!buffer.isEmpty())
{
QByteArray data;
int length = buffer.size() < chunk_sz ? buffer.size() : chunk_sz;
for (int i = 0; i < length; i++)
data.append(buffer.dequeue());
emit processedBytes(data);
}
}
示例2: result
KisPaintInformation
KisToolFreehandHelper::Private::getStabilizedPaintInfo(const QQueue<KisPaintInformation> &queue,
const KisPaintInformation &lastPaintInfo)
{
KisPaintInformation result(lastPaintInfo);
if (queue.size() > 1) {
QQueue<KisPaintInformation>::const_iterator it = queue.constBegin();
QQueue<KisPaintInformation>::const_iterator end = queue.constEnd();
/**
* The first point is going to be overridden by lastPaintInfo, skip it.
*/
it++;
int i = 2;
if (smoothingOptions->stabilizeSensors()) {
while (it != end) {
qreal k = qreal(i - 1) / i; // coeff for uniform averaging
result = KisPaintInformation::mix(k, *it, result);
it++;
i++;
}
} else {
while (it != end) {
qreal k = qreal(i - 1) / i; // coeff for uniform averaging
result = KisPaintInformation::mixOnlyPosition(k, *it, result);
it++;
i++;
}
}
}
return result;
}
示例3: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
FrameReader r;
r.setMedia(a.arguments().last());
QQueue<qint64> t;
int count = 0;
qint64 t0 = QDateTime::currentMSecsSinceEpoch();
while (r.readMore()) {
while (r.hasEnoughVideoFrames()) {
const VideoFrame f = r.getVideoFrame(); //TODO: if eof
if (!f)
continue;
count++;
//r.readMore();
const qint64 now = QDateTime::currentMSecsSinceEpoch();
const qint64 dt = now - t0;
t.enqueue(now);
printf("decode @%.3f count: %d, elapsed: %lld, fps: %.1f/%.1f\r", f.timestamp(), count, dt, count*1000.0/dt, t.size()*1000.0/(now - t.first()));fflush(0);
if (t.size() > 10)
t.dequeue();
}
}
while (r.hasVideoFrame()) {
const VideoFrame f = r.getVideoFrame();
qDebug("pts: %.3f", f.timestamp());
}
qDebug("read done");
return 0;
}
示例4: service
int BleRtmpSendThread::service(BleRtmpMuxer & muxer)
{
int ret = BLE_SUCESS;
if ((ret = sendVideoSh(muxer)) != BLE_SUCESS) {
return ret;
}
if ((ret = sendAudioSh(muxer)) != BLE_SUCESS) {
return ret;
}
while (!m_stop) {
QQueue<BleAVPacket *> pkts = BleAVQueue::instance()->dequeue();
if (pkts.isEmpty()) {
msleep(50);
continue;
}
BleAutoLocker(m_mutex);
while (!pkts.empty()) {
BleAVPacket *pkt = pkts.dequeue();
BleAutoFree(BleAVPacket, pkt);
MStream &data = pkt->data;
if (pkt->pktType == Packet_Type_Video) {
if (muxer.addH264(data, pkt->dts) != TRUE ) {
ret = BLE_RTMPSEND_ERROR;
break;
}
m_videoKbps += (data.size() + 11);
m_fps += 1;
} else if (pkt->pktType == Packet_Type_Audio) {
if (muxer.addAAC(data, pkt->dts) != TRUE ) {
ret = BLE_RTMPSEND_ERROR;
break;
}
m_audioKbps += (data.size() + 11);
}
m_sendDataCount += (data.size() + 11);
}
// if send failed, then pkts may has some pkt
// we should delete it.
for (int i = 0; i < pkts.size(); ++i) {
BleAVPacket *pkt = pkts.at(i);
BleFree(pkt);
}
}
return ret;
}
示例5: indexElementoMenor
int Grafo::indexElementoMenor(QQueue<vertice*> cola)
{
int indexMin = 0;
for(int i = 0; i < cola.size(); i++)
{
if(cola.at(i)->costoHastaAhora < cola.at(indexMin)->costoHastaAhora)
indexMin = i;
}
return indexMin;
}
示例6: startDownload
void OpenstreetmapMapProvider::startDownload(QQueue<Tile>& queue)
{
mIsRunning = true;
while (queue.size() > 0)
{
Tile info = queue.dequeue();
fetchTile(info);
}
}
示例7: main
/*
Send-Import:
Count 1658 bytes
Dict Size 76272 bytes
Data Size 91315785 bytes
Total Size 91392057 bytes
Recv-Export:
Count 1616 bytes
Dict Size 74340 bytes
Data Size 91309561 bytes
Total Size 91383901 bytes
*/
int main ( int argc, char** argv ) {
/*
__attach();
__attachInterfaces();
__attachGenerics();
__attachAssets();*/
__attachQImage();
__attachWavefront();
recvCB [ UUIDManager::createUUID("AssetImplementation::World") ] = OnReceiveWorld;
recvCB [ UUIDManager::createUUID("AssetImplementation::WorldCell") ] = OnReceiveWorldCell;
recvCB [ UUIDManager::createUUID("AssetImplementation::GameObject") ] = OnReceiveGameObject;
recvCB [ UUIDManager::createUUID("AssetImplementation::GameEntity") ] = OnReceiveGameEntity;
recvCB [ UUIDManager::createUUID("AssetImplementation::Light") ] = OnReceiveLight;
recvCB [ UUIDManager::createUUID("AssetImplementation::Image") ] = OnReceiveImage;
recvCB [ UUIDManager::createUUID("AssetImplementation::WavefrontMaterial") ] = OnReceiveWavefrontMaterial;
recvCB [ UUIDManager::createUUID("AssetImplementation::Mesh") ] = OnReceiveMesh;
SimpleTcpEndPoint::Options options;
options.serverIP = "127.0.0.1";
options.connectionPort = 3000;
SimpleTcpEndPoint client ( options );
if ( client.open() == false ) exit ( -1 );
// reception de l'UUID du monde
QUuid worldID = receiveUUID(client);
fetchResource(worldID);
while ( true ) {
if ( resourceToFetch.size() > 0 ) {
QUuid uuid = resourceToFetch.dequeue();
if ( recvResources.find(uuid)==recvResources.end () ) {
sendUUID(client, uuid);
receiveResource(client);
}
}
else break;
}
std::cout << "Received " << received << " bytes" << std::endl;
/*
sendUUID(client,worldID);
Assets::WorldPtr world = receiveResource(client).dynamicCast<Assets::World>();
std::cout << world->mTypeID.toString().toStdString() << std::endl;
std::cout << UUIDManager::createUUID("AssetImplementation::World").toString().toStdString() << std::endl;
for ( int i = 0 ; i < world->getSize < QUuid > ( "Cells" ) ; i ++ ) {
sendUUID(client,world->get < QUuid > ( "Cells", i ));
Assets::WorldCellPtr cell = receiveResource(client).dynamicCast<Assets::WorldCell>();
}
*/
client.close ();
ResourceHolder::Export( "world.binary" );
return 0;
}
示例8: loading
void QuickAndroidTests::loading()
{
QStringList res;
QQueue<QString> queue;
queue.enqueue(":/QuickAndroid");
QQmlEngine engine;
engine.addImportPath("qrc:///");
while (queue.size()) {
QString path = queue.dequeue();
QDir dir(path);
QFileInfoList infos = dir.entryInfoList(QStringList());
for (int i = 0 ; i < infos.size();i++) {
QFileInfo info = infos.at(i);
if (info.fileName() == "." || info.fileName() == "..")
continue;
if (info.isDir()) {
queue.enqueue(info.absoluteFilePath());
continue;
}
QUrl url = info.absoluteFilePath().remove(0,1);
url.setScheme("qrc");
if (info.suffix() != "qml") {
continue;
}
QFile file(":" + url.path());
QVERIFY(file.open(QIODevice::ReadOnly));
QString content = file.readAll();
content = content.toLower();
// Skip singleton module as it can not be loaded directly
if (content.indexOf("pragma singleton") != -1) {
qDebug() << QString("%1 : Skipped (singleton)").arg(url.toString());
continue;
}
QQmlComponent comp(&engine);
comp.loadUrl(url);
if (comp.isError()) {
qDebug() << QString("%1 : Load Failed. Reason : %2").arg(info.absoluteFilePath()).arg(comp.errorString());
}
QVERIFY(!comp.isError());
qDebug() << QString("%1 : Passed").arg(info.absoluteFilePath());
}
}
}
示例9: paintPath
void TrafficGraphWidget::paintPath(QPainterPath &path, QQueue<float> &samples)
{
int h = height() - YMARGIN * 2, w = width() - XMARGIN * 2;
int sampleCount = samples.size(), x = XMARGIN + w, y;
if(sampleCount > 0) {
path.moveTo(x, YMARGIN + h);
for(int i = 0; i < sampleCount; ++i) {
x = XMARGIN + w - w * i / DESIRED_SAMPLES;
y = YMARGIN + h - (int)(h * samples.at(i) / fMax);
path.lineTo(x, y);
}
path.lineTo(x, YMARGIN + h);
}
}
示例10: on_horizontalScrollBar_sliderMoved
void MainWindow::on_horizontalScrollBar_sliderMoved(int position) {
QString q = QString::number(widget.PlotView0->xAxis->range().size(), 0, 0);
// qDebug(q.toStdString().c_str());
int n = (qLL.size()) / 100000;
if (qAbs(widget.PlotView0->xAxis->range().center() - position) > 0.01) // if user is dragging plot, we don't want to replot twice
{
widget.PlotView0->xAxis->setRange((n + 1) * position, widget.PlotView0->xAxis->range().size(), Qt::AlignLeft);
widget.PlotView0->replot();
}
if (qAbs(widget.PlotView1->xAxis->range().center() - position) > 0.01) // if user is dragging plot, we don't want to replot twice
{
widget.PlotView1->xAxis->setRange((n + 1) * position, widget.PlotView1->xAxis->range().size(), Qt::AlignLeft);
widget.PlotView1->replot();
}
}
示例11: ffmpegGraphPlot
void MainWindow::ffmpegGraphPlot(QQueue<int> LL, QQueue<int> RR) {
qLL = LL;
qRR = RR;
widget.PlotView0->addGraph();
widget.PlotView0->graph()->setPen(QPen(Qt::blue));
widget.PlotView0->graph()->setBrush(QBrush(QColor(0, 0, 255, 20)));
widget.PlotView0->graph()->setPen(QPen(Qt::red));
widget.PlotView1->addGraph();
widget.PlotView1->graph()->setPen(QPen(Qt::blue));
widget.PlotView1->graph()->setBrush(QBrush(QColor(0, 0, 255, 20)));
widget.PlotView1->graph()->setPen(QPen(Qt::red));
//int size = qLL.size();
int size = LL.size() / 5;
QVector<double> x0(size), y0(size); // initialize with entries 0..100
QVector<double> x1(size), y1(size); // initialize with entries 0..100
for (int i = 0; i < size; i += 1) {
x0[i] = i; // x goes from -1 to 1
y0[i] = LL.at(i); // let's plot a quadratic function
// y1[i] = LL.at(i+1); // let's plot a quadratic function
// y0[i] = rand()*1000;
// cout<<LL.at(i)<<endl;
// y1[i] = Samples[100000 + i + 1] / 20; // let's plot a quadratic function
}
widget.PlotView0->addGraph();
widget.PlotView0->graph(0)->setData(x0, y0);
widget.PlotView0->xAxis->setRange(0, 1000);
widget.PlotView0->yAxis->setRange(-255, 255);
widget.PlotView0->replot();
widget.PlotView1->addGraph();
widget.PlotView1->graph(0)->setData(x0, y0);
widget.PlotView1->xAxis->setRange(0, 1000);
widget.PlotView1->yAxis->setRange(-255, 255);
widget.PlotView1->replot();
cout << size << endl;
}
示例12: run
void BleEncoderThread::run()
{
BleImageProcessThread * imageProcessThread = dynamic_cast<BleImageProcessThread *> (m_imageProcessThread);
BleAssert(imageProcessThread);
while (!m_stop) {
QQueue<BleImage*> images = BleAVContext::instance()->captureThread->getQueue();
// if can't get image, then sleep 50 ms.
if (images.isEmpty()) {
msleep(5);
continue;
}
while (!images.empty()) {
BleImage * image = images.dequeue();
BleAutoFree(BleImage, image);
if (image->dataSize <= 0) continue;
IplImage* imgYUV = cvCreateImage(cvSize(image->width, image->height * 3 / 2), IPL_DEPTH_8U, 1);
IplImage *cvImage = cvCreateImageHeader(cvSize(image->width, image->height), IPL_DEPTH_8U, 3);
cvImage->imageData = image->data;
cvImage->imageDataOrigin = image->data;
cvCvtColor(cvImage, imgYUV, CV_BGR2YUV_I420);
m_x264Encoder->encode((uchar*)imgYUV->imageData, image->pts, image->opaque);
cvReleaseImageHeader(&cvImage);
cvReleaseImage(&imgYUV);
if (m_stop) break;
}
// do clean
for (int i = 0; i > images.size(); ++i) {
BleImage *img = images.at(i);
BleFree(img);
}
}
log_trace("BleEncoderThread exit normally.");
}
示例13: tryConnectListList
QQueue<QString> Data::getListList()
{
tryConnectListList();
QQueue <QString> q;
QSqlQuery query;
query.exec("select * from listlist order by id;");
while (query.next())
{
q.push_back(query.value(0).toString());
qDebug() << "Get list" << query.value(1).toInt() << ":" << query.value(0).toString()<< endl;
}
if (q.size() == 0)
{
query.exec("insert into listlist"
"(name, id, count) values('默认列表', 0, 0);");
Data::changeListCount(1);
q.push_back(QString("默认列表"));
qDebug() << "Create list:默认列表" << endl;
}
return q;
}
示例14: tryConnectMusicList
QQueue<MusicInfo> Data::getMusicList(QString listName)
{
tryConnectMusicList();
listName = listName.replace("'", "''");
QQueue <MusicInfo> q;
MusicInfo musicInfo;
QSqlQuery query;
query.exec("select * from musiclist where listname = '"+listName+"' order by id;");
while (query.next())
{
musicInfo.setDir(query.value(2).toString());
musicInfo.setName(query.value(3).toString());
musicInfo.setArtist(query.value(4).toString());
q.push_back(musicInfo);
qDebug() << "Get music:" << query.value(3).toString() << endl;
}
int all = q.size();
query.exec("select * from listlist;");
QString str =
QString("update listlist set count = %1 "
"where name = '%2';").arg(all).arg(listName);
query.exec(str);
return q;
}
示例15: doTileLayout
//protected
void MapGraphicsView::doTileLayout()
{
//Calculate the center point and polygon of the viewport in QGraphicsScene coordinates
const QPointF centerPointQGS = _childView->mapToScene(_childView->width()/2.0,
_childView->height()/2.0);
QPolygon viewportPolygonQGV;
viewportPolygonQGV << QPoint(0,0) << QPoint(0,_childView->height()) << QPoint(_childView->width(),_childView->height()) << QPoint(_childView->width(),0);
const QPolygonF viewportPolygonQGS = _childView->mapToScene(viewportPolygonQGV);
const QRectF boundingRect = viewportPolygonQGS.boundingRect();
//We exaggerate the bounding rect for some purposes!
QRectF exaggeratedBoundingRect = boundingRect;
exaggeratedBoundingRect.setSize(boundingRect.size()*2.0);
exaggeratedBoundingRect.moveCenter(boundingRect.center());
//We'll mark tiles that aren't being displayed as free so we can use them
QQueue<MapTileGraphicsObject *> freeTiles;
QSet<QPointF> placesWhereTilesAre;
foreach(MapTileGraphicsObject * tileObject, _tileObjects)
{
if (!tileObject->isVisible() || !exaggeratedBoundingRect.contains(tileObject->pos()))
{
freeTiles.enqueue(tileObject);
tileObject->setVisible(false);
}
else
placesWhereTilesAre.insert(tileObject->pos());
}
const quint16 tileSize = _tileSource->tileSize();
const quint32 tilesPerRow = sqrt((long double)_tileSource->tilesOnZoomLevel(this->zoomLevel()));
const quint32 tilesPerCol = tilesPerRow;
const qint32 perSide = qMax(boundingRect.width()/tileSize,
boundingRect.height()/tileSize) + 3;
const qint32 xc = qMax((qint32)0,
(qint32)(centerPointQGS.x() / tileSize) - perSide/2);
const qint32 yc = qMax((qint32)0,
(qint32)(centerPointQGS.y() / tileSize) - perSide/2);
const qint32 xMax = qMin((qint32)tilesPerRow,
xc + perSide);
const qint32 yMax = qMin(yc + perSide,
(qint32)tilesPerCol);
for (qint32 x = xc; x < xMax; x++)
{
for (qint32 y = yc; y < yMax; y++)
{
const QPointF scenePos(x*tileSize + tileSize/2,
y*tileSize + tileSize/2);
bool tileIsThere = false;
if (placesWhereTilesAre.contains(scenePos))
tileIsThere = true;
if (tileIsThere)
continue;
//Just in case we're running low on free tiles, add one
if (freeTiles.isEmpty())
{
MapTileGraphicsObject * tileObject = new MapTileGraphicsObject(tileSize);
tileObject->setTileSource(_tileSource);
_tileObjects.insert(tileObject);
_childScene->addItem(tileObject);
freeTiles.enqueue(tileObject);
}
//Get the first free tile and make it do its thing
MapTileGraphicsObject * tileObject = freeTiles.dequeue();
if (tileObject->pos() != scenePos)
tileObject->setPos(scenePos);
if (tileObject->isVisible() != true)
tileObject->setVisible(true);
tileObject->setTile(x,y,this->zoomLevel());
}
}
//If we've got a lot of free tiles left over, delete some of them
while (freeTiles.size() > 2)
{
MapTileGraphicsObject * tileObject = freeTiles.dequeue();
_tileObjects.remove(tileObject);
_childScene->removeItem(tileObject);
delete tileObject;
}
}