当前位置: 首页>>代码示例>>C++>>正文


C++ QTime::restart方法代码示例

本文整理汇总了C++中QTime::restart方法的典型用法代码示例。如果您正苦于以下问题:C++ QTime::restart方法的具体用法?C++ QTime::restart怎么用?C++ QTime::restart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTime的用法示例。


在下文中一共展示了QTime::restart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateData

void MainWindow::updateData(QString data)
{
    QTime t;
    t.start();

    m_model.loadFromCSV( data );

    qDebug("Time for loading data %s: %d ms", data.toLatin1().constData(), t.elapsed());
    t.restart();

    QSize size1 = QSize( 200, 200 );
    QSize size2 = QSize( 800, 800 );
    m_pix1 = drawIntoPixmap( size1, m_chart );
    m_pix2 = drawIntoPixmap( size2, m_chart );

    qDebug("Time for drawing pixmap %s: %d ms", data.toLatin1().constData(), t.elapsed());
    t.restart();

    m_lines->setModel( &m_model );

    qDebug("Time for setting model %s: %d ms", data.toLatin1().constData(), t.elapsed());
    t.restart();

    m_smallChart1->setPixmap( m_pix1 );
    m_smallChart2->setPixmap( m_pix2 );

    m_smallChart1->show();
    m_smallChart2->show();

    qDebug("Time for setting pixmap %s: %d ms", data.toLatin1().constData(), t.elapsed());
    t.restart();

}
开发者ID:KDE,项目名称:kdiagram,代码行数:33,代码来源:mainwindow.cpp

示例2: computeBaseState

void PlayerHandler::computeBaseState()
{
	static QTime reloj=QTime::currentTime();
	static float xant;
	static float yant;
// 	float x = posIface->data->pose.pos.y*1000.;
// 	float z = posIface->data->pose.pos.x*1000.;
// 	client->Read();
	float x = pos->GetYPos()*1000.;
	float z = pos->GetXPos()*1000.;
	float dl = float ( x - xant );
	float dr = float ( z - yant );
	xant = bState.x;
	yant = bState.z;
	float incA = sqrt(dl*dl+dr*dr);
	mutex->lock();
		//Compute increments through robot kinematics
		client->Read();
		bState.adv = incA;
// 		bState.rotV = -posIface->data->velocity.yaw;
		bState.rotV = -pos->GetYawSpeed();
		bState.advV = incA / (float) reloj.restart() * 1000;
		bState.rotV = -pos->GetYawSpeed() / (float) reloj.restart() * 1000;
		bState.isMoving = (bState.advV!=0 or bState.rotV!=0);
		//position
// 		bState.alpha = posIface->data->pose.yaw - alfa;
		bState.alpha = pos->GetYaw();
		bState.x = ( r00*x + r01*z ) - (r00*t0 + r01*t1);
		bState.z = ( r10*x + r11*z ) - (r10*t0 + r11*t1);
// 		qDebug()<<bState.x<<bState.z<<rtod(bState.alpha);
	mutex->unlock();
}
开发者ID:BasilMVarghese,项目名称:robocomp-robolab,代码行数:32,代码来源:playerhandler.cpp

示例3: if

QGraphicsScene * ClusteredArranger::arrange(SegmentList const & segments) const {
   QGraphicsScene * arrangement = new QGraphicsScene();

   QTime time;
   time.start();

   // determine background
   Segment * background = determineBackground(segments);
   SegmentList segmentsWOBack = removeBackground(segments, background);
   arrangement->setBackgroundBrush(QBrush(QColor(background->color().toQRgb())));
   segmentsWOBack.calculateFeatureVariances();

   // initialize layout
   //initializeLayout(segmentsWOBack, segmentsWOBack.featX(), segmentsWOBack.featY());
   initializeLayout(segmentsWOBack, xAxisBox->currentIndex(), yAxisBox->currentIndex());

   // find clusters
   time.restart();
   QList<SegmentList> clusters = meanShift(segmentsWOBack);
   qDebug("Segments clustered in %f seconds", time.restart()/1000.0);
   qDebug("  %d clusters found", clusters.size());

   // refine clusters
   //int counter = 0;
   foreach (SegmentList cluster, clusters) {
      if (clusterBox->currentIndex() == 0) {
         refineLayoutCircles(cluster);
      }
      else if (clusterBox->currentIndex() == 1) {
         refineLayoutPiles(cluster);
      }

      // debug output
      /*QGraphicsScene scene;
      scene.setBackgroundBrush(QBrush(QColor(255, 255, 255)));
      foreach(Segment * const segment, cluster) {
         scene.addItem(segment->toQGraphicsItem());
         // without the following line QPainter tends to crash
         scene.width();
      }
      ++counter;
      saveScene(&scene, QString("Test%1.png").arg(counter, 2));*/
   }

   // refine layout
   if (clusterBox->currentIndex() == 0) {
      refineLayoutByPlace(clusters);
   }
   else if (clusterBox->currentIndex() == 1) {
      refineLayoutBySize(clusters);
   }

   // convert the segments to QGraphicsItems and add to QGraphicsScene
   foreach(Segment const * const segment, segmentsWOBack) {
      arrangement->addItem(segment->toQGraphicsItem());
      // without the following line QPainter tends to crash
      arrangement->width();
   }
开发者ID:Svensational,项目名称:tidy,代码行数:58,代码来源:clusteredarranger.cpp

示例4:

VoiceSignature::VoiceSignature(const Sound& sound)
{
 	static uint temp_wind=0, temp_fft=0, temp_moy=0;
 	QTime t;
 	t.start();
	
	unsigned int start , stop;
	if(!window(sound,&start,&stop))
	{
		kWarning() << "No voice found in the sound" 	;
		return;
	}
	
	temp_wind+=t.restart();

	uint length=stop-start;

	for(int wind=0; wind<WINDOW_NUMBER; wind++)
	{
		unsigned int w_start=MAX(start, start+ (int)((wind - WINDOW_SUPER)*length/WINDOW_NUMBER));
		unsigned int w_stop =MIN(stop , start+ (int)((wind+1.0+WINDOW_SUPER)*length/WINDOW_NUMBER));
		

		QVector<double> fourrier=fft(sound, w_start,w_stop);
		
		temp_fft+=t.restart();

		//MEL conversion
		double mel_start=HZ_TO_MEL(FFT_RANGE_INF);
		uint mel_stop=HZ_TO_MEL(FFT_RANGE_SUP);
		
		for(int four=0; four<FOUR_NUMBER; four++)
		{
			unsigned int wf_start=mel_start + four*(mel_stop-mel_start)/FOUR_NUMBER;
			unsigned int wf_stop=mel_start + (four+1)*(mel_stop-mel_start)/FOUR_NUMBER;

			unsigned int f_start=MEL_TO_HZ( wf_start )*fourrier.size()/sound.fs();
			unsigned int f_stop=MEL_TO_HZ( wf_stop )*fourrier.size()/sound.fs();
			unsigned int f_size=f_stop-f_start;
			
			double nb=0;
			for(uint f=f_start; f<f_stop; f++)
			{
				int freq=f*fourrier.size()/sound.fs();
				nb+=fourrier[f]*FFT_PONDERATION(freq);
			}
			nb/=(f_size);
			data[wind][four]=nb;
		}
		
		temp_moy+=t.restart();

	}
	
//	kDebug() << "wind: "<< temp_wind << "  - fft: " << temp_fft << "  - moy: " << temp_moy;
}
开发者ID:KDE,项目名称:kde-workspace,代码行数:56,代码来源:voicesignature.cpp

示例5: applyEffect

void App::applyEffect(QRectF rect, float zoom, float opacityA, float opacityB, float opacityC, float opacityD)
{
	QTime t;
	t.start();

	QRectF targetRect(0, 0, m_displayWidth, m_displayHeight);
	QRectF sourceRect(rect.x() / zoom, rect.y() / zoom, rect.width(), rect.height());

	QImage resultImage(QSize(m_displayWidth, m_displayHeight), QImage::Format_ARGB32_Premultiplied);

	QImage baseImage = Helper::createImageFromTile(m_tile, m_displayWidth, m_displayHeight);
	baseImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);

	QDir imageDir = QDir::current();
	imageDir.cd("app/native/assets/images");

	QImage overlay1(imageDir.absoluteFilePath("effect1.png"));
	overlay1.convertToFormat(QImage::Format_ARGB32_Premultiplied);

	QImage overlay2(imageDir.absoluteFilePath("effect2.png"));
	overlay2.convertToFormat(QImage::Format_ARGB32_Premultiplied);

	QImage overlay3(imageDir.absoluteFilePath("effect3.png"));
	overlay3.convertToFormat(QImage::Format_ARGB32_Premultiplied);

	QImage overlay4(imageDir.absoluteFilePath("effect4.png"));
	overlay4.convertToFormat(QImage::Format_ARGB32_Premultiplied);

	qDebug() << "TIME: loading images:" << t.elapsed();
	t.restart();

	QPainter p(&resultImage);
	p.drawImage(targetRect, baseImage, sourceRect);
	p.setCompositionMode(QPainter::CompositionMode_SourceOver);
	p.setOpacity(opacityA);
	p.drawImage(0,0, overlay1);
	p.setOpacity(opacityB);
	p.drawImage(0,0, overlay2);
	p.setOpacity(opacityC);
	p.drawImage(0,0, overlay3);
	p.setOpacity(opacityD);
	p.drawImage(0,0, overlay4);
	p.end();

	qDebug() << "TIME drawing final image:" << t.elapsed();
	t.restart();

	m_bigImageCache = resultImage;

	bb::cascades::Image cimg = Helper::convertImage(resultImage);
	setBigImage(cimg);

	qDebug() << "TIME converting final image:" << t.elapsed();
	t.restart();
}
开发者ID:kodira,项目名称:pattern,代码行数:55,代码来源:app.cpp

示例6: testOctree

void testOctree(CMesh& mesh, std::vector<unsigned int>& test_indeces, std::vector<vcg::Point3f>& randomSamples)
{
    std::cout << "==================================================="<< std::endl;
    std::cout << "Octree" << std::endl;
    QTime time;
    time.start();

    // Construction of the uniform grid
    typedef vcg::Octree<CMesh::VertexType, CMesh::VertexType::ScalarType> MeshGrid;
    MeshGrid uniformGrid;
    uniformGrid.Set(mesh.vert.begin(), mesh.vert.end());
    std::cout << "Build: " << time.elapsed() <<  " ms" << std::endl;

    // Test with the radius search
    std::cout << "Radius search (" << num_test << " tests)"<< std::endl;
    float  avgTime = 0.0f;
    for (int ii = 0; ii < num_test; ii++)
    {
        time.restart();
        std::vector<CMesh::VertexPointer> vertexPtr;
        std::vector<CMesh::VertexType::CoordType> points;
        std::vector<float> dists;
        vcg::tri::GetInSphereVertex(mesh, uniformGrid, mesh.vert[test_indeces[ii]].cP(), queryDist, vertexPtr, dists, points);
        avgTime += time.elapsed();
    }
    std::cout << "Time (radius = " << queryDist << "): " << avgTime << " ms (mean " << avgTime / num_test << "ms)"  << std::endl;

    // Test with the k-nearest search
    std::cout << "k-Nearest search (" << num_test*10 << " tests)"<< std::endl;
    avgTime = 0.0f;
    for (int ii = 0; ii < num_test * 10; ii++)
    {
        time.restart();
        std::vector<CMesh::VertexPointer> vertexPtr;
        std::vector<CMesh::VertexType::CoordType> points;
        std::vector<float> dists;
        vcg::tri::GetKClosestVertex(mesh, uniformGrid, kNearest, mesh.vert[test_indeces[ii]].cP(), mesh.bbox.Diag(), vertexPtr, dists, points);
        avgTime += time.elapsed();
    }
    std::cout << "Time (k = " << kNearest << "): " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)"  << std::endl;

    // Test with the Closest search
    std::cout << "Closest search (" << num_test*10 << " tests)"<< std::endl;
    avgTime = 0.0f;
    for (int ii = 0; ii < num_test * 10; ii++)
    {
        time.restart();
        float minDist;
        vcg::tri::GetClosestVertex(mesh, uniformGrid, randomSamples[ii], mesh.bbox.Diag(), minDist);
        avgTime += time.elapsed();
    }
    std::cout << "Time : " << avgTime << " ms (mean " << avgTime / (num_test * 10) << "ms)"  << std::endl << std::endl;
}
开发者ID:caomw,项目名称:vcglib-1,代码行数:53,代码来源:trimesh_indexing.cpp

示例7: testPerfectSpatialHashing

void testPerfectSpatialHashing(CMesh& mesh, std::vector<unsigned int>& test_indeces)
{
    std::cout << "==================================================="<< std::endl;
    std::cout << "Perfect Spatial Hashing" << std::endl;
    QTime time;
    time.start();

    // Construction of the uniform grid
    typedef vcg::SpatialHashTable<CMesh::VertexType, CMesh::VertexType::ScalarType> MeshGrid;
    MeshGrid uniformGrid;
    uniformGrid.Set(mesh.vert.begin(), mesh.vert.end());
    std::cout << "Build: " << time.elapsed() <<  " ms" << std::endl;

    // Test with the radius search
    std::cout << "Radius search (" << num_test << " tests)"<< std::endl;
    float  avgTime = 0.0f;
    for (int ii = 0; ii < num_test; ii++)
    {
        time.restart();
        std::vector<CMesh::VertexPointer> vertexPtr;
        std::vector<CMesh::VertexType::CoordType> points;
        std::vector<float> dists;
        vcg::tri::GetInSphereVertex(mesh, uniformGrid, mesh.vert[test_indeces[ii]].cP(), queryDist, vertexPtr, dists, points);
        avgTime += time.elapsed();
    }
    std::cout << "Time (radius = " << queryDist << "): " << avgTime << " ms (mean " << avgTime / num_test << "ms)"  << std::endl << std::endl;
}
开发者ID:caomw,项目名称:vcglib-1,代码行数:27,代码来源:trimesh_indexing.cpp

示例8: runSync

bool MyProcess::runSync(SCRef rc, QByteArray* ro, QObject* rcv, SCRef buf) {
	async = false;
	runCmd = rc;
	runOutput = ro;
	receiver = rcv;
	if (runOutput)
		runOutput->clear();

	setupSignals();
	if (!launchMe(runCmd, buf))
		return false;

	QTime t;
	t.start();

	busy = true; // we have to wait here until we exit

	while (busy) {
		waitForFinished(20); // suspend 20ms to let OS reschedule

		if (t.elapsed() > 200) {
			EM_PROCESS_EVENTS;
			t.restart();
		}
	}
	return !isErrorExit;
}
开发者ID:slyshykO,项目名称:qgit,代码行数:27,代码来源:myprocess.cpp

示例9: waitForFinished

bool QGalleryTrackerResultSet::waitForFinished(int msecs)
{
    Q_D(QGalleryTrackerResultSet);

    QTime timer;
    timer.start();

    do {
        if (d->flags & QGalleryTrackerResultSetPrivate::Active) {
            if (d->waitForSyncFinish(msecs)) {
                d->parserThread.wait();

                d->_q_parseFinished();

                if (!(d->flags & QGalleryTrackerResultSetPrivate::Active))
                    return true;
            } else {
                return false;
            }
        } else if (d->flags & (QGalleryTrackerResultSetPrivate::Refresh)) {
            d->update();
        } else {
            return true;
        }
    } while ((msecs -= timer.restart()) > 0);

    return false;
}
开发者ID:mer-packages,项目名称:qtdocgallery,代码行数:28,代码来源:qgallerytrackerresultset.cpp

示例10: HasSomethingToPaste

static bool HasSomethingToPaste (kpMainWindow *mw)
{
#if DEBUG_KP_MAIN_WINDOW
    kdDebug () << "kpMainWindow(" << mw->name () << "):HasSomethingToPaste()" << endl;
    QTime timer;
    timer.start ();
#else
    (void) mw;
#endif

    bool hasSomething = false;

    QMimeSource *ms = QApplication::clipboard ()->data (QClipboard::Clipboard);
    if (ms)
    {
        // It's faster to test for QTextDrag::canDecode() first due to the
        // lazy evaluation of the '||' operator.
        hasSomething = (QTextDrag::canDecode (ms) ||
                        kpSelectionDrag::canDecode (ms));
    #if DEBUG_KP_MAIN_WINDOW
        kdDebug () << "\t" << mw->name () << "***canDecode=" << timer.restart () << endl;
        for (int i = 0; ; i++)
        {
            const char *fmt = ms->format (i);
            if (!fmt)
                break;

            kdDebug () << "\t'" << fmt << "'" << endl;
        }
    #endif
    }

    return hasSomething;
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:34,代码来源:kpmainwindow_edit.cpp

示例11: compute

void SpecificWorker::compute()
{
	static QTime reloj = QTime::currentTime();
	static int fps=0;
	
	Mat frame, frameRGB;
	grabber.read(frame); 	
	cvtColor( frame, frameRGB, CV_BGR2RGB );
	memcpy( &writeBuffer[0], frameRGB.data, frameRGB.size().area() * 3);
// 	qDebug() << "Reading..."; // at" << grabber.get(CV_CAP_PROP_FPS) << "fps";
// 	imshow("img", frame);
	QMutexLocker ml(mutex);
	readBuffer.swap( writeBuffer);
	
	if( reloj.elapsed() > 1000)
	{
		qDebug() << "Grabbing at"<< fps << "FPS ";
		fps=0;
		reloj.restart();
	}
	fps++;
	
	//if(waitKey(30) >= 0) exit(-1);
	
}
开发者ID:robocomp,项目名称:robocomp-robolab,代码行数:25,代码来源:specificworker.cpp

示例12: run

    void run(){

        // we should be executed on the main queue
        MU_ASSERT_EQUAL_HEX(QDispatch::currentQueue().native(), dispatch_get_main_queue());

        // assert that we can really get the timer
        MU_ASSERT_EQUAL_HEX(QDispatchTimer::current(), tested_timer);

        // test the timer interval (but only after the second run
        // as the first one will be started immediately
        if(counter > 0) {
            long diff = checked_time.elapsed();
            MU_DESC_ASSERT_LESS_THAN_EQUAL("timer not too late", diff, 3*1000);
            MU_DESC_ASSERT_LESS_THAN_EQUAL("timer not too early", 1*1000, diff);
        }

        checked_time.restart();

        // only pass when the timer fired at least 5 times
        MU_MESSAGE("\t%i", counter);
        if(counter < 5)
            counter++;
        else {
            MU_PASS("");
        }
    }
开发者ID:RunLoopStudio,项目名称:xdispatch,代码行数:26,代码来源:Qt_dispatch_timer.cpp

示例13: work3

int work3() {
    int x = 0;
    QApplication a(x,0);
//1396","uid":"359887
    DanmuConnection dc;
    dc.debugFlag = true;
    dc.login("aabbeaabbe","aabbdaabbd", "359887","1396");
    QTime t;
    t.start();
    int count = 0;
     x = 1;
    while(true) {

        if (t.elapsed() >5000)  {
            count+=123123;
            //a = dc.postDanmu(QString ::number(count));
            //   QJsonObject({"action":1,"cmdid":"blockuser","ip":"111.8.57.138","msg":"111","nam
            //   e":"九千万亿电竞女神","type":1,"uid":100305463})

            x = 1-x;
           t.restart();
        }
        QCoreApplication::processEvents();
    }
    return a.exec();

}
开发者ID:xh286286,项目名称:hasee_project_swarm,代码行数:27,代码来源:main.cpp

示例14: scanMaps

void Dialog::scanMaps(const QString &folderName)
{
    CatchChallenger::DebugClass::redirection=true;

    QTime startTime;
    startTime.restart();

    scanFolderMap(QDir(folderName));
    scanFolderPosition(QDir(folderName));

    qDebug() << startTime.elapsed();

    QString html="<ul>";
    QHash<QString,Map_full>::const_iterator i = other_map.constBegin();
    while (i != other_map.constEnd()) {
        if(i.value().log.size()>0)
        {
            html+="<li>"+i.key();
            html+="<ul><li>"+i.value().log.join("</li><li>")+"</li></ul>";
            html+="</li>";
        }
        ++i;
    }
    html+="</ul>";
    ui->textEdit->setHtml(html);
}
开发者ID:tgjklmda,项目名称:CatchChallenger,代码行数:26,代码来源:Dialog.cpp

示例15: qgetenv

/**
 * Flushes the contents of the \a windowSurface into the screen area of \a widget.
 * \a tlwOffset is the position of the top level widget relative to the window surface.
 * \a region is the region to be updated in \a widget coordinates.
 */
static inline void qt_flush(QWidget *widget, const QRegion &region, QWindowSurface *windowSurface,
                            QWidget *tlw, const QPoint &tlwOffset)
{
    Q_ASSERT(widget);
    Q_ASSERT(!region.isEmpty());
    Q_ASSERT(windowSurface);
    Q_ASSERT(tlw);

#if !defined(QT_NO_PAINT_DEBUG)
    static int flushUpdate = qgetenv("QT_FLUSH_UPDATE").toInt();
    if (flushUpdate > 0)
        QWidgetBackingStore::showYellowThing(widget, region, flushUpdate * 10, false);
#endif

    //The performance hit by doing this should be negligible. However, be aware that
    //using this FPS when you have > 1 windowsurface can give you inaccurate FPS
    static bool fpsDebug = qgetenv("QT_DEBUG_FPS").toInt();
    if (fpsDebug) {
        static QTime time = QTime::currentTime();
        static int frames = 0;

        frames++;

        if(time.elapsed() > 5000) {
            double fps = double(frames * 1000) /time.restart();
            fprintf(stderr,"FPS: %.1f\n",fps);
            frames = 0;
        }
    }
    if (widget != tlw)
        windowSurface->flush(widget, region, tlwOffset + widget->mapTo(tlw, QPoint()));
    else
        windowSurface->flush(widget, region, tlwOffset);
}
开发者ID:fluxer,项目名称:katie,代码行数:39,代码来源:qbackingstore.cpp


注:本文中的QTime::restart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。