本文整理汇总了C++中QTimer::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ QTimer::stop方法的具体用法?C++ QTimer::stop怎么用?C++ QTimer::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTimer
的用法示例。
在下文中一共展示了QTimer::stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreach
foreach (Sliver *sliver, slivers) {
sliver->status = Sliver::STATUS_OFFLINE;
sliverHash[sliver->name] = sliver;
if (relayEnabled()) {
installProgram(sliver);
addSliverConnection(sliver);
} else {
if (sliver->IPv6.isEmpty()) {
qDebug() << "No ip, getting address";
getIpAddress(sliver);
installProgram(sliver);
} else {
addSliverConnection(sliver);
QTimer *timer = new QTimer(this);
//if there's a specified IP address, give the connection some time before running the script setting things up.
connect(timer, &QTimer::timeout, [timer, sliver, this]() {
qDebug() << "Checking connection status";
if (sliver->status == sliver->STATUS_OFFLINE) {
qDebug() << "Still offline, reinstalling";
installProgram(sliver);
}
timer->stop();
timer->deleteLater();
});
timer->start(3000);
}
}
QTimer *timer = new QTimer(this);
//Will try to connect as long as the sliver is not connected
connect(timer, &QTimer::timeout, [timer, sliver, this]() {
if (sliver->status != sliver->STATUS_CONNECTED) {
qDebug() << "Retryign connection";
addSliverConnection(sliver);
} else {
timer->stop();
timer->deleteLater();
}
static int time = 0;
time+=3;
//if (time > 35) {
// shutDownNodeprogs(QList<Sliver*>() << sliver);
// installProgram(sliver);
// time = 0;
// }
});
timer->start(3000);
}
示例2: Disconnect
bool Irc::Disconnect()
{
//quick out
if(!m_connected)
return true;
//create timer connected to the timeout slot
QTimer timer;
connect(&timer,SIGNAL(timeout()),this,SLOT(OnTimeout()));
//start timer
timer.start(CONNECTION_TIMEOUT);
//disconnect from host
m_socket.disconnectFromHost();
if(m_socket.state() != 0) // if 0, then already disconnected
m_eventloop.exec();
//stop timer
timer.stop();
//disconnect timer from timeout slot
disconnect(&timer,SIGNAL(timeout()), this,SLOT(OnTimeout()));
return !m_connected; //return inverse of m_connected. eg. if m_connected false then the function succeeded
}
示例3: Connect
bool Irc::Connect()
{
//quick out
if(m_connected)
return true;
//create timer connected to the timeout slot
QTimer timer;
connect(&timer,SIGNAL(timeout()),this,SLOT(OnTimeout()));
//start timer
timer.start(CONNECTION_TIMEOUT);
//connect to host
m_socket.connectToHost(m_host, m_port);
if(m_socket.state() < 3) // if smaller then not yet connected
m_eventloop.exec();
//stop timer
timer.stop();
//disconnect timer from timeout slot
disconnect(&timer,SIGNAL(timeout()), this,SLOT(OnTimeout()));
return m_connected;
}
示例4: postSynchronously
void CometClient::postSynchronously(const QString &requestUrlString, const QString &postDataString, int requestIdentifier, int timeoutMilliseconds) {
QUrl requestUrl(requestUrlString);
QNetworkRequest request(requestUrl);
request.setAttribute(QNetworkRequest::User, QVariant(requestIdentifier));
request.setRawHeader("X-Requested-With", "XMLHttpRequest");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QByteArray data;
data.append(postDataString);
QNetworkReply *reply = nam->post(request, data);
requestsMade.insert(reply);
QTimer timer; //the timer handles timeout event
timer.setSingleShot(true);
QEventLoop loop;
QObject::connect(reply, SIGNAL(readyRead()), &loop, SLOT(quit()));
QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
timer.start(timeoutMilliseconds);
loop.exec(QEventLoop::ExcludeUserInputEvents);
if(timer.isActive()) {
timer.stop();
} else {
qDebug() << "postSynchronously() timeout occured";
//reply->abort();
}
}
示例5: cancel_me
//virtual
void PromiseTimer::cancel_me()
{
if(!isActivating()) {
timer.stop();
delete this;
}
}
示例6: main
int main(int argc, char *argv[]) {
#ifndef WIN32
XInitThreads();
#endif
QApplication app(argc, argv);
MyWidget *window = new MyWidget;
//see my_widget.h for controller and cache creation
window->show();
window->update();
QTimer *timer = new QTimer(window);
QObject::connect(timer, SIGNAL(timeout()), window, SLOT(update()));
timer->start(2000);
QTimer *timer1 = new QTimer(window);
QObject::connect(timer1, SIGNAL(timeout()), window, SLOT(updateGL()));
timer1->start(20);
QTimer *timer2 = new QTimer(window);
QObject::connect(timer2, SIGNAL(timeout()), window, SLOT(close()));
timer2->start(20000);
app.exec();
timer->stop();
timer1->stop();
timer2->stop();
QTest::qWait(2000);
qDebug("main program calling destruction");
return 0;
}
示例7: stop
void PictureFlowAnimator::stop(int slide)
{
step = 0;
target = slide;
frame = slide << 16;
animateTimer.stop();
}
示例8: mouseReleaseEvent
void CQplayerGUI::mouseReleaseEvent(QMouseEvent *e)
{
static int init = 0;
static QTimer timer;
static QPoint p;
touchAdjust(e);
if(init == 0){
init++;
timer.setSingleShot(true);
timer.setInterval(1000);
connect(&timer,SIGNAL(timeout()),this,SLOT(clickStateReset()));
}
if(!ui->frameMovie->geometry().contains(e->globalPos()))
return;
clickCnt++;
if(clickCnt == 1){ //第一次点击
p = e->pos();
timer.start();
}
else { //第二次点击
clickCnt = 0;
timer.stop();
if((e->pos() - p).manhattanLength() < 200)//两次点击距离10pix之内为有效双击
media->screenNormal();
}
}
示例9: Analyze
void XFoilAnalysisDlg::Analyze()
{
m_pctrlCancel->setText(tr("Cancel"));
m_pctrlSkip->setEnabled(true);
//all set to launch the analysis
//create a timer to update the output at regular intervals
QTimer *pTimer = new QTimer;
connect(pTimer, SIGNAL(timeout()), this, SLOT(OnProgress()));
pTimer->setInterval(QXDirect::s_TimeUpdateInterval);
pTimer->start();
//Launch the task
m_pXFoilTask->run();
pTimer->stop();
delete pTimer;
OnProgress();
m_pXFoilTask->m_OutStream.flush();
m_bErrors = m_pXFoilTask->m_bErrors;
if(m_bErrors)
{
m_pctrlTextOutput->insertPlainText(tr(" ...some points are unconverged"));
m_pctrlTextOutput->ensureCursorVisible();
}
m_pctrlCancel->setText(tr("Close"));
m_pctrlSkip->setEnabled(false);
update();
}
示例10: sendBlockingNetRequest
bool Utils::sendBlockingNetRequest(const QUrl& theUrl, QString& reply)
{
QNetworkAccessManager manager;
QEventLoop q;
QTimer tT;
manager.setProxy(M_PREFS->getProxy(QUrl("http://merkaartor.be")));
tT.setSingleShot(true);
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
connect(&manager, SIGNAL(finished(QNetworkReply*)),
&q, SLOT(quit()));
QNetworkReply *netReply = manager.get(QNetworkRequest(theUrl));
tT.start(M_PREFS->getNetworkTimeout());
q.exec();
if(tT.isActive()) {
// download complete
tT.stop();
} else {
return false;
}
reply = netReply->readAll();
return true;
}
示例11: MrccatoCommand
// Callback when media keys are pressed
void MediakeyCaptureItemPrivate::MrccatoCommand(TRemConCoreApiOperationId aOperationId,
TRemConCoreApiButtonAction aButtonAct)
{
if (aButtonAct == ERemConCoreApiButtonRelease) {
m_timer->stop();
m_volumeDownPressed = false;
m_volumeUpPressed = false;
return;
}
switch (aOperationId) {
case ERemConCoreApiVolumeUp:
m_volumeUpPressed = true;
m_volumeDownPressed = false;
d_ptr->increaseVolume();
if (aButtonAct == ERemConCoreApiButtonPress) m_timer->start();
return;
case ERemConCoreApiVolumeDown:
m_volumeDownPressed = true;
m_volumeUpPressed = false;
d_ptr->decreaseVolume();
if (aButtonAct == ERemConCoreApiButtonPress) m_timer->start();
break;
default:
m_volumeDownPressed = false;
m_volumeUpPressed = false;
return;
}
}
示例12: testGetRequest
void testGetRequest()
{
QString url = "http://m.baidu.com/s?word=abc&ts=1223145&rq=ab";
QNetworkAccessManager* networkAccessManager = new QNetworkAccessManager();
QNetworkRequest request;
request.setUrl(QUrl(url));
request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
//request.setRawHeader("Accept-Encoding", "gzip, deflate, sdch");
request.setRawHeader("Accept-Language", "h-CN,zh;q=0.8");
request.setRawHeader("Host", "m.baidu.com");
request.setRawHeader("Referer", "http://m.baidu.com");
request.setRawHeader("Connection", "keep-alive");
request.setRawHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36");
QNetworkReply* reply = networkAccessManager->get(request);
QEventLoop loop;
NetWorkCookieJar* cookieJar = new NetWorkCookieJar(networkAccessManager);
networkAccessManager->setCookieJar(cookieJar);
QTimer timer;
timer.setSingleShot(true);
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
timer.start(5000);
loop.exec();
timer.stop();
qDebug() << request.rawHeaderList();
qDebug() << reply->readAll();
qDebug() << cookieJar->getCookies();
networkAccessManager->deleteLater();
reply->deleteLater();
}
示例13: processAlgorithm
QVariantMap QgsFileDownloaderAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
mFeedback = feedback;
QString url = parameterAsString( parameters, QStringLiteral( "URL" ), context );
QString outputFile = parameterAsFileOutput( parameters, QStringLiteral( "OUTPUT" ), context );
QEventLoop loop;
QTimer timer;
QgsFileDownloader *downloader = new QgsFileDownloader( QUrl( url ), outputFile, QString(), true );
connect( mFeedback, &QgsFeedback::canceled, downloader, &QgsFileDownloader::cancelDownload );
connect( downloader, &QgsFileDownloader::downloadError, this, &QgsFileDownloaderAlgorithm::reportErrors );
connect( downloader, &QgsFileDownloader::downloadProgress, this, &QgsFileDownloaderAlgorithm::receiveProgressFromDownloader );
connect( downloader, &QgsFileDownloader::downloadExited, &loop, &QEventLoop::quit );
connect( &timer, &QTimer::timeout, this, &QgsFileDownloaderAlgorithm::sendProgressFeedback );
downloader->startDownload();
timer.start( 1000 );
loop.exec();
timer.stop();
bool exists = QFileInfo( outputFile ).exists();
if ( !feedback->isCanceled() && !exists )
throw QgsProcessingException( tr( "Output file doesn't exist." ) );
QVariantMap outputs;
outputs.insert( QStringLiteral( "OUTPUT" ), exists ? outputFile : QString() );
return outputs;
}
示例14: get
bool Spider::get(NetWorker *instance,QString url){
QString address1 = "http://192.168.60.131:9200/bcc/_search?q=url:\"";
QString address2 = "http://192.168.60.132:9200/bcc/_search?q=url:\"";
QString address3 = "http://192.168.60.133:9200/bcc/_search?q=url:\"";
QString address4 = "http://192.168.60.134:9200/bcc/_search?q=url:\"";
//QString url = "http://192.168.60.134:9200/bcc/_search?q=url:\"http://www.lagou.co/jobs/218581.html?source=search\"";
int count = rand();
qDebug()<<address1+url+"\"";
if(count%4==0){
instance->get(address1+url+"\"");
}else if(count%4==1){
instance->get(address2+url+"\"");
}else if(count%4==2){
instance->get(address3+url+"\"");
}else {
instance->get(address4+url+"\"");
};
QEventLoop eventLoop;
QTimer timer;
timer.setSingleShot(true);
QObject::connect(instance, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QObject::connect(&timer,SIGNAL(timeout()),&eventLoop,SLOT(quit()));
timer.start(3000);
eventLoop.exec(); //block until finish
if(timer.isActive()){
timer.stop();
//return false;
}
return instance->flag;
}
示例15: quit
void InputDaemon::quit()
{
stopped = true;
// Wait for SDL to finish. Let worker destructor close SDL.
// Let InputDaemon destructor close thread instance.
if (graphical)
{
QEventLoop q;
QTimer temptime;
connect(eventWorker, SIGNAL(finished()), &q, SLOT(quit()));
connect(&temptime, SIGNAL(timeout()), &q, SLOT(quit()));
eventWorker->stop();
temptime.start(1000);
q.exec();
temptime.stop();
}
else
{
eventWorker->stop();
}
delete eventWorker;
eventWorker = 0;
}