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


C++ QTimer::isActive方法代码示例

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


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

示例1: statistics

uint IcdPrivate::statistics(QList<IcdStatisticsResult>& stats_results)
{
    QTimer timer;
    QVariant reply;
    QVariantList vl;
    uint signals_left, total_signals;
    IcdStatisticsResult result;

    clearState();
    reply = mDBus->call(ICD_DBUS_API_STATISTICS_REQ);
    if (reply.type() != QVariant::List)
        return 0;
    vl = reply.toList();
    if (vl.isEmpty())
        return 0;
    reply = vl.first();
    if (reply.type() != QVariant::UInt)
        return 0;
    signals_left = total_signals = reply.toUInt();

    if (!signals_left)
        return 0;

    timer.setSingleShot(true);
    timer.start(timeout);
    stats_results.clear();
    while (signals_left) {
	mInterface.clear();
	while (timer.isActive() && mInterface.isEmpty()) {
	    QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
	}

	if (!timer.isActive()) {
	    total_signals = 0;
	    break;
	}

	if (mSignal != ICD_DBUS_API_STATISTICS_SIG) {
	    continue;
	}

	if (mError.isEmpty()) {
  	    get_statistics_all_result(mArgs, result);
	    stats_results << result;
	    signals_left--;
	} else {
	    qWarning() << "Error:" << mError;
	    break;
	}
    }
    timer.stop();

    return total_signals;
}
开发者ID:RS102839,项目名称:qt,代码行数:54,代码来源:maemo_icd.cpp

示例2: waitForSignal

bool QQmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
    QEventLoop loop;
    QTimer timer;
    timer.setSingleShot(true);
    QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
    QObject::connect(receiver, member, &loop, SLOT(quit()));
    timer.start(timeout);
    loop.exec();
    if (!timer.isActive())
        qWarning("waitForSignal %s timed out after %d ms", member, timeout);
    return timer.isActive();
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:12,代码来源:debugutil.cpp

示例3: 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;
}
开发者ID:huyangenruc,项目名称:bccspider,代码行数:30,代码来源:spider_service.cpp

示例4: post

void Spider::post(const QMap<QString, QVariant> &map,NetWorker *instance){
    QString address1 = "http://192.168.60.131:9200/bcc/1";
    QString address2 = "http://192.168.60.132:9200/bcc/1";
    QString address3 = "http://192.168.60.133:9200/bcc/1";
    QString address4 = "http://192.168.60.134:9200/bcc/1";
    QJsonDocument doc=QJsonDocument::fromVariant(QVariant(map));
    QByteArray j=doc.toJson();
    QString result(j);
    qDebug()<<result;
    int count = rand();
    if(count%4==0){
        instance->post(QUrl(address1),j);
    }else if(count%4==1){
        instance->post(QUrl(address2),j);
    }else if(count%4==2){
        instance->post(QUrl(address3),j);
    }else {
        instance->post(QUrl(address4),j);
    }
    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(2000);
    eventLoop.exec();       //block until finish
    if(timer.isActive()){
        timer.stop();
    }
}
开发者ID:huyangenruc,项目名称:bccspider,代码行数:30,代码来源:spider_service.cpp

示例5: stop

void StratumClient::stop() {
  QEventLoop waitLoop;
  QTimer disconnectTimer;
  disconnectTimer.setSingleShot(true);
  disconnectTimer.setInterval(RECONNECT_TIMER_INTERVAL);
  connect(m_socket, &QTcpSocket::disconnected, &waitLoop, &QEventLoop::quit);
  connect(&disconnectTimer, &QTimer::timeout, &waitLoop, &QEventLoop::quit);
  m_socket->disconnectFromHost();
  disconnectTimer.start();
  if (m_socket->state() != QTcpSocket::UnconnectedState) {
    waitLoop.exec();
  }

  if (!disconnectTimer.isActive()) {
    m_socket->abort();
    disconnectTimer.stop();
  }

  if (m_reconnectTimerId != -1) {
    killTimer(m_reconnectTimerId);
    m_reconnectTimerId = -1;
  }

  if (m_responseTimerId != -1) {
    killTimer(m_responseTimerId);
    m_responseTimerId = -1;
  }

  m_activeRequestMap.clear();
  m_currentSessionId.clear();
  QWriteLocker lock(&m_jobLock);
  m_currentJob = Job();
}
开发者ID:SpaceAdventure,项目名称:bitcediwallet,代码行数:33,代码来源:StratumClient.cpp

示例6: isActive

bool QTimerProto::isActive() const
{
  QTimer *item = qscriptvalue_cast<QTimer*>(thisObject());
  if (item)
    return item->isActive();
  return false;
}
开发者ID:AlFoX,项目名称:qt-client,代码行数:7,代码来源:qtimerproto.cpp

示例7: action_forecast_send

void ClientBlock::action_forecast_send()
{
    if (client_actions->contains("setforecast")) {
        QNetworkAccessManager* m_manager;
        m_manager = new QNetworkAccessManager(this);
        connect(m_manager, SIGNAL(finished(QNetworkReply*)),
                 this, SLOT(replyFinished(QNetworkReply*)));

        QUrl url = QUrl("http://api.openweathermap.org/data/2.5/weather?q=shebekino&APPID=5437baa043723201a6fb434e5366ec57", QUrl::TolerantMode);
        QNetworkRequest rq=QNetworkRequest(url);
        m_manager->get(rq);

        QTimer timer;
        timer.setSingleShot(true);
        QEventLoop loop;
        connect(m_manager,  SIGNAL(finished(QNetworkReply*)), &loop, SLOT(quit()) );
        connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
        timer.start(5000);
        loop.exec();

        if(timer.isActive()) {
            QTimer::singleShot(1000, &loop, SLOT(quit()));
            loop.exec();
        }

        delete m_manager;
    }
开发者ID:bukmare,项目名称:ESP_CStation,代码行数:27,代码来源:clientblock.cpp

示例8: 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;
}
开发者ID:4x4falcon,项目名称:fosm-merkaartor,代码行数:27,代码来源:Utils.cpp

示例9: 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();
    }
}
开发者ID:TediumRemedy,项目名称:TediumRemedy,代码行数:28,代码来源:cometclient.cpp

示例10: downloadUrlToString

/**
 * QML wrapper to download an url and returning it as text
 *
 * @param url
 * @return {QString} the content of the downloaded url
 */
QString ScriptingService::downloadUrlToString(QUrl url) {
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    QEventLoop loop;
    QTimer timer;

    timer.setSingleShot(true);
    connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
    connect(manager, SIGNAL(finished(QNetworkReply *)), &loop, SLOT(quit()));

    // 10 sec timeout for the request
    timer.start(10000);

    QNetworkRequest networkRequest = QNetworkRequest(url);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
    networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute,
                                true);
#endif

    QNetworkReply *reply = manager->get(networkRequest);
    loop.exec();

    // if we didn't get a timeout let us return the content
    if (timer.isActive()) {
        // get the text from the network reply
        QString data = reply->readAll();
        if (data.size() > 0) {
            return data;
        }
    }

    // timer elapsed, no reply from network request or empty data
    return "";
}
开发者ID:danielng01,项目名称:QOwnNotes,代码行数:40,代码来源:scriptingservice.cpp

示例11: start

void PictureFlowAnimator::start(int slide) {
  target = slide;
  if (!animateTimer.isActive() && state) {
    step = (target < state->centerSlide.slideIndex) ? -1 : 1;
    animateTimer.start(30);
  }
}
开发者ID:EvorzStudios,项目名称:plexydesk,代码行数:7,代码来源:pictureflow.cpp

示例12: triggerTimer

    void triggerTimer()
    {
        if (timer.isActive()) {
            timer.stop();
        }

        timer.start(200);
    }
开发者ID:KDE,项目名称:kdepim,代码行数:8,代码来源:searchbar.cpp

示例13: doConnect

bool InfinityProtocol::doConnect(const Peer& peer)
{
    if ( isConnectedTo(peer) ) {
        return true;
    }

    QEventLoop loop;
    m_connection = QSharedPointer<Kobby::Connection>(new Kobby::Connection(peer.hostname, peer.port, QString(), this));
    m_browserModel = QSharedPointer<QInfinity::BrowserModel>(new QInfinity::BrowserModel( this ));
    m_browserModel->setItemFactory(new Kobby::ItemFactory( this ));
    QObject::connect(m_connection.data(), SIGNAL(ready(Connection*)), &loop, SLOT(quit()));
    QObject::connect(m_connection.data(), SIGNAL(error(Connection*,QString)), &loop, SLOT(quit()));
    m_connection->prepare();

    m_notePlugin = new Kobby::NotePlugin(this);
    m_browserModel->addPlugin(*m_notePlugin);

    QTimer timeout;
    timeout.setSingleShot(true);
    // Give it a bit more time for connecting than usual, our connection method is complicated sometimes
    timeout.setInterval(connectTimeout() * 1000 * 3);
    connect(&timeout, SIGNAL(timeout()), &loop, SLOT(quit()));
    timeout.start();
    loop.exec();
    if ( ! timeout.isActive() || ! m_connection->xmppConnection() ) {
        kDebug() << "failed to look up hostname";
        error(KIO::ERR_UNKNOWN_HOST, peer.hostname);
        return false;
    }
    m_connection->open();
    m_browserModel->addConnection(static_cast<QInfinity::XmlConnection*>(m_connection->xmppConnection()), "kio_root");

    connect(browser(), SIGNAL(connectionEstablished(const QInfinity::Browser*)),
            &loop, SLOT(quit()));
    connect(browser(), SIGNAL(error(const QInfinity::Browser*,QString)),
            &loop, SLOT(quit()));
    loop.exec();
    if ( ! timeout.isActive() || browser()->connectionStatus() != INF_BROWSER_OPEN ) {
        kDebug() << "failed to connect";
        error(KIO::ERR_COULD_NOT_CONNECT, QString("%1:%2").arg(peer.hostname, QString::number(peer.port)));
        return false;
    }

    m_connectedTo = peer;
    return true;
}
开发者ID:KDE,项目名称:kte-collaborative,代码行数:46,代码来源:kio_infinity.cpp

示例14: applyFilter

// Core 
bool FilterWebExportVMustPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParameterSet & /*parent*/, vcg::CallBackPos * cb)
{
	if (ID(filter) == FP_WEB_EXPORT)
	{
		CMeshO &m=md.mm()->cm;

		QNetworkAccessManager NAManager;

		// STEP 1: check if the server works (by requesting the list of application templates)
		// (note that this list is not used)
		QUrl urlTest ("http://pipeline.v-must.net/api/v1/bundles");

		QNetworkRequest request1(urlTest);

		QNetworkReply *reply1 = NAManager.get(request1);
		QTimer timer;
		timer.setSingleShot(true);
		timer.start(5000);

		QEventLoop eventLoop;
		connect(reply1, SIGNAL(finished()), &eventLoop, SLOT(quit()));
		connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
		eventLoop.exec();   // block the http request for 5 seconds

		delete reply1;

		if (timer.isActive())
		{
			timer.stop();

			// STEP 2: preparing the bucket for the processing

			QUrl urlBucket("http://pipeline.v-must.net/api/v1/buckets");
			QNetworkRequest request2(urlBucket);
			request2.setRawHeader("Accept", "application/json");
			request2.setRawHeader("Accept-Encoding", "gzip, deflate, compress");
			request2.setRawHeader("Content-Type", "application/octet-stream");
			request2.setRawHeader("Host", "pipelineserver.ltd");
			request2.setRawHeader("X-Filename", "test.ply");

			QNetworkReply *reply2 = NAManager.get(request2);
			connect(reply2, SIGNAL(finished()), &eventLoop, SLOT(quit()));
			eventLoop.exec();   // block the http request

			// STEP 3: launch the processing according to the selected template
		}
		else
		{
			QMessageBox::warning(0, tr("V-Must CIF API"), tr("Server is time out. Please, re-try later."));
		}



	}

	return true;
}
开发者ID:jaesungj,项目名称:EECS481meshLab,代码行数:58,代码来源:filter_web_export.cpp

示例15: fps

void KbManager::fps(int framerate){
    QTimer* timer = eventTimer();
    if(!timer)
        return;
    if(timer->isActive())
        timer->setInterval(1000 / framerate);
    else
        timer->start(1000 / framerate);
}
开发者ID:Zyx-A,项目名称:ckb-next,代码行数:9,代码来源:kbmanager.cpp


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