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


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

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


在下文中一共展示了QTimer::deleteLater方法的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);
    }
开发者ID:dreibh,项目名称:nornetdemo,代码行数:51,代码来源:democore.cpp

示例2: slotNotificationDisplayed

void Sound::slotNotificationDisplayed(Snore::Notification notification)
{
    if (notification.hints().value("silent").toBool()) {
        return;
    }
    m_player->setVolume(settingsValue(QLatin1String("Volume")).toInt());

    QString sound = notification.hints().value("sound").toString();
    if (sound.isEmpty()) {
        sound = settingsValue(QLatin1String("Sound")).toString();
    }
    snoreDebug(SNORE_DEBUG) << "SoundFile:" << sound;
    if (!sound.isEmpty()) {
        m_player->setMedia(QUrl::fromLocalFile(sound));
        snoreDebug(SNORE_DEBUG) << "SoundFile:" << m_player->media().canonicalUrl();
        m_player->play();
        QTimer *timeout = new QTimer(this);
        timeout->setSingleShot(true);
        timeout->setInterval(notification.timeout() * 1000);
        connect(timeout, &QTimer::timeout, [this, timeout] {
            m_player->stop();
            timeout->deleteLater();
        });
    }
}
开发者ID:jendas1,项目名称:Snorenotify,代码行数:25,代码来源:sound.cpp

示例3: StopUpdateCheck

void UpdaterPrivate::StopUpdateCheck(int delay, bool async) {
    if (main_process == nullptr || main_process->state() == QProcess::NotRunning) {
        return;
    }

    if (delay > 0) {
        main_process->terminate();
        if (async) {
            QTimer* timer = new QTimer(this);
            timer->setSingleShot(true);

            connect(timer, &QTimer::timeout, [=]() {
                StopUpdateCheck(0, false);
                timer->deleteLater();
            });

            timer->start(delay);
        } else {
            if (!main_process->waitForFinished(delay)) {
                main_process->kill();
                main_process->waitForFinished(100);
            }
        }
    } else {
        main_process->kill();
        main_process->waitForFinished(100);
    }
}
开发者ID:JayFoxRox,项目名称:citra,代码行数:28,代码来源:updater.cpp

示例4: doLater

void Controller::doLater(int msec, QObject *receiver, lambda func)  {
    QTimer *timer = new QTimer(receiver);
    QObject::connect(timer, &QTimer::timeout, receiver,
                     [timer, func](){ func(); timer->deleteLater(); });
    timer->setInterval(msec);
    timer->start();
}
开发者ID:Jocix123,项目名称:flameshot,代码行数:7,代码来源:controller.cpp

示例5: activator

void UbuntuPlugin::activator()
{
    QTimer *timer = (QTimer*)sender();
    QWidget *w = sender()->property("widget").value<QWidget*>();

    /*w->activateWindow();
    w->raise();*/
    X11Util::forceActivateWindow(w->winId());
    timer->deleteLater();
}
开发者ID:Ri0n,项目名称:QtNote,代码行数:10,代码来源:ubuntu.cpp

示例6: main

int main(int argc, char** argv) {
    auto glversion = gl::getAvailableVersion();
    auto major = GL_GET_MAJOR_VERSION(glversion);
    auto minor = GL_GET_MINOR_VERSION(glversion);

    if (glversion < GL_MAKE_VERSION(4, 1)) {
        MessageBoxA(nullptr, "Interface requires OpenGL 4.1 or higher", "Unsupported", MB_OK);
        return 0;
    }
    QGuiApplication app(argc, argv);

    bool quitting = false;
    // FIXME need to handle window closing message so that we can stop the timer
    GLWindow* window = new GLWindow();
    window->create();
    window->show();
    window->setSurfaceType(QSurface::OpenGLSurface);
    window->setFormat(getDefaultOpenGLSurfaceFormat());
    bool contextCreated = false;
    QTimer* timer = new QTimer();
    QObject::connect(timer, &QTimer::timeout, [&] {
        if (quitting) {
            return;
        }
        if (!contextCreated) {
            window->createContext();
            contextCreated = true;
        }
        if (!window->makeCurrent()) {
            throw std::runtime_error("Failed");
        }
        glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        window->swapBuffers();
        window->doneCurrent();
    });
    // FIXME need to handle window closing message so that we can stop the timer
    QObject::connect(&app, &QCoreApplication::aboutToQuit, [&] {
        quitting = true;
        QObject::disconnect(timer, &QTimer::timeout, nullptr, nullptr);
        timer->stop();
        timer->deleteLater();
    });

    timer->setInterval(15);
    timer->setSingleShot(false);
    timer->start();
    app.exec();
    return 0;
}
开发者ID:Atlante45,项目名称:hifi,代码行数:50,代码来源:main.cpp

示例7: timer

void ScriptEngine::timer()
{
    QTimer *t = (QTimer*) sender();
    if (timerEvents[t].isFunction()) {
        timerEvents[t].call();
    } else if (timerEvents[t].isString()) {
        eval(timerEvents[t].toString());
    } else {
        warn("ScriptEngine::timer", "this is a bug, report it. code is not string or function");
        return;
    }

    if (t->isSingleShot()) {
        timerEvents.remove(t);
        t->deleteLater();
    }
}
开发者ID:ElementsPO,项目名称:pokemon-online,代码行数:17,代码来源:scriptengine.cpp

示例8: init

void NetworkManager::init()
{
    QTimer *dbusCheckTimer = new QTimer;
    dbusCheckTimer->setInterval(100);
    dbusCheckTimer->setSingleShot(false);

    auto checkFunc = [=] {
        if (!m_networkInter->isValid())
            return;

        QTimer::singleShot(100, this, &NetworkManager::reloadDevices);
        QTimer::singleShot(150, this, &NetworkManager::reloadActiveConnections);
        dbusCheckTimer->deleteLater();
    };

    connect(dbusCheckTimer, &QTimer::timeout, checkFunc);
    dbusCheckTimer->start();
}
开发者ID:linuxdeepin,项目名称:dde-dock,代码行数:18,代码来源:networkmanager.cpp

示例9: sendRequest

void Configuration::sendRequest(const QUrl &url)
{
	d->req.setUrl(url);
	QNetworkReply *reply = d->net->get(d->req);
	d->requestcache << reply;
	QTimer *timer = new QTimer(this);
	timer->setSingleShot(true);
	connect(timer, &QTimer::timeout, [=]{
		timer->deleteLater();
		if(!d->requestcache.contains(reply))
			return;
		d->requestcache.removeAll(reply);
		reply->deleteLater();
		qDebug() << "Request timed out";
		Q_EMIT finished(false, tr("Request timed out"));
	});
	timer->start(30*1000);
}
开发者ID:rrebane,项目名称:qt-common,代码行数:18,代码来源:Configuration.cpp

示例10: unsetAllTimers

int ScriptEngine::unsetAllTimers()
{
    int i = 0;
    QHashIterator <QTimer*, QScriptValue> it (timerEvents);
    while (it.hasNext()) {
        it.next();
        QTimer *timer = it.key();

        timer->stop();
        timer->blockSignals(true);

        timerEvents.remove(timer);
        timer->deleteLater();
        i++;
    }

    return i;
}
开发者ID:ElementsPO,项目名称:pokemon-online,代码行数:18,代码来源:scriptengine.cpp

示例11: unsetTimer

bool ScriptEngine::unsetTimer(int timerId)
{
    QHashIterator <QTimer*, QScriptValue> it (timerEvents);
    while (it.hasNext()) {
        it.next();
        QTimer *timer = it.key();

        if (timer->timerId() == timerId) {
            timer->stop();
            timer->blockSignals(true);

            timerEvents.remove(timer);
            timer->deleteLater();
            return true; // Timer found.
        }
    }
    warn ("unsetTimer(timerId)", "no timer with that id");
    return false; // No timer found.
}
开发者ID:ElementsPO,项目名称:pokemon-online,代码行数:19,代码来源:scriptengine.cpp

示例12: executeCommand

void SchedulerServiceThread::executeCommand(){

    Parser::QBoolParser::resetInstance();
    Parser::QMathParser *parser = new Parser::QMathParser(this);
    Parser::QScriptBlock *block = new Parser::QScriptBlock(parser);

    QString s = sender()->objectName();
    s = s.split("\n").last();

    if(sender()->objectName().startsWith("timer\n")){
        s = s.split("\n").last();

        //Code nehmen und ausführen
        block->exec(QString::fromUtf8(QByteArray::fromHex(this->_instructions->value(s)->scriptCode.toUtf8())));
        this->_instructions->value(s)->count++;

        //Speichern
        this->saveToFile();
        parser->deleteLater();
        return;
    }

    //Allgemeine Daten holen
    SchedulerServiceThread::Task *task = this->_instructions->value(s);
    QTimer *timer = qobject_cast<QTimer *>(sender());

    //Block ausführen & Done
    block->exec(QString::fromUtf8(QByteArray::fromHex(task->scriptCode.toUtf8())));
    task->done = true;

    //Timer löschen
    timer->stop();
    timer->deleteLater();
    parser->deleteLater();

    //Speichern
    this->saveToFile();
}
开发者ID:okirmis,项目名称:sdb-server,代码行数:38,代码来源:schedulerservicethread.cpp

示例13: modulesLoaded

void
ModuleManager::loadModules( Phase phase )
{
    //FIXME: When we depend on Qt 5.4 this ugly hack should be replaced with
    //       QTimer::singleShot.
    QTimer* timer = new QTimer();
    timer->setSingleShot( true );
    connect( timer, &QTimer::timeout,
             this, [ this, timer, phase ]()
    {
        foreach ( const QString& moduleName, Settings::instance()->modules( phase ) )
        {
            if ( !m_availableModules.contains( moduleName ) )
            {
                cDebug() << "Module" << moduleName << "not found in module search paths."
                         << "\nCalamares will now quit.";
                qApp->exit( 1 );
                return;
            }
            if ( m_availableModules.value( moduleName )->isLoaded() )
            {
                cDebug() << "Module" << moduleName << "already loaded.";
                continue;
            }

            doLoad( moduleName );
        }
        emit modulesLoaded( phase );
        // Loading sequence:
        // 1) deps are already fine. check if we have all the modules needed by the roster
        // 2) ask ModuleManager to load them from the list provided by Settings
        // 3) MM must load them asyncly but one at a time, by calling Module::loadSelf
        // 4) Module must have subclasses that reimplement loadSelf for various module types

        timer->deleteLater();
    });
开发者ID:maui-packages,项目名称:calamares,代码行数:36,代码来源:ModuleManager.cpp

示例14: if

void MessageBoxType4::initPost(const QJsonObject &post) {
    QPalette pal;
    pal.setColor(QPalette::Background, Qt::white);

    QFont nameFont;
    nameFont.setBold(true);

    QString offsetStyleSheet = "margin-left: " + QString::number(MessageBoxType4::commentOffset) + ";";

    userName = new QLabel(this);
    userName->setFont(nameFont);
    userName->setStyleSheet(offsetStyleSheet + "color: gray;");

    memberText = new QLabel(this);
    memberText->setAutoFillBackground(true);
    memberText->setPalette(pal);

    commentText = new QLabel(this);
    commentText->setAutoFillBackground(true);
    //commentText->setPalette(pal);
    commentText->setStyleSheet(offsetStyleSheet + "background-color: white;"
                                                  "color: gray");

    if(parentWidget() != NULL) {
        memberText->setFixedWidth(parentWidget()->width() - 40);
        commentText->setFixedWidth(parentWidget()->width() - 40 - MessageBoxType4::commentOffset);
    }

    QJsonArray postBody = post["body"].toArray();

    QString text = "";
    QString comment = "";
    for(int i = 0; i < postBody.count(); i++) {
        QJsonObject obj = postBody[i].toObject();
        int bodyType = obj["bodyType"].toInt();
        if(bodyType == 1)
            text += obj["text"].toString();
        else if(bodyType == 4) {
            QJsonObject commentJson = obj["comment"] .toObject();

            userName->setText(commentJson["sendUserName"].toString());
            commentText->setText(commentJson["text"].toString());
            commentText->setWordWrap(true);
            commentText->setMinimumHeight(commentText->sizeHint().height());
        }

    }
    memberText->setText(text);
    memberText->setWordWrap(true);
    memberText->setMinimumHeight(memberText->sizeHint().height());

    layout->addWidget(memberText, 1, 0);
    layout->addWidget(userName, 2, 0);
    layout->addWidget(commentText, 3, 0);

    setFixedHeight(sizeHint().height());

    QTimer *timer = new QTimer;
    QObject::connect(timer, &QTimer::timeout, [=] {
        timer->stop();
        timer->deleteLater();
        emit boxFinished(this);
    });
    timer->start(100);


}
开发者ID:tbcey74123,项目名称:7gogoViewer,代码行数:67,代码来源:messageboxtype4.cpp

示例15: data

void Reader_RFM008B::readData()
{
    if(m_serial->canReadLine()){
        if(!allLines){

//            Logger::instance()->writeRecord(Logger::severity_level::debug, m_module, Q_FUNC_INFO, QString("Reading Data..."));

            QByteArray buffer = m_serial->readAll();
            QRegExp regex;
            regex.setPattern("(L(\\d{2})?W)\\s([0-9a-fA-F]{4})\\s([0-9a-fA-F]{16})");

            QString data(buffer);
            data.remove(QRegExp("[\\n\\t\\r]"));

            //        if(m_outReceived.device()){
            //            m_outReceived << data;
            //            m_outReceived.flush();
            //        }


            int pos = regex.indexIn(data);
            if(pos != -1){
                // The first string in the list is the entire matched string.
                // Each subsequent list element contains a string that matched a
                // (capturing) subexpression of the regexp.
                QStringList matches = regex.capturedTexts();

                // crear RFIDData
                QRegularExpression regexCode;
                regexCode.setPattern("([0-9a-fA-F]{4})(\\s)([0-9a-fA-F]{16})");
                QRegularExpressionMatch match = regexCode.match(matches.at(0));

                if(m_outCaptured.device()){
                    m_outCaptured << matches.at(0);
                    m_outCaptured.flush();
                }

                if(match.hasMatch()) {
                    Rfiddata *data = new Rfiddata(this);

                    // Id collector from configuration file
                    data->setIdpontocoleta(idCollector);

                    // This module can read from only one antena, so the idAntena is static.
                    int idAntena = 1;
                    data->setIdantena(idAntena);

                    qlonglong applicationcode = match.captured(1).toLongLong();
                    qlonglong identificationcode = match.captured(3).toLongLong();

                    /*
                 * Filter by time. If more than one transponder was read in a time interval only one of them will be persisted.
                 * A QMap is used to verify if each new data that had arrived was already read in this interval.
                 */
                    if(!m_map.contains(identificationcode)){

                        QTimer *timer = new QTimer;
                        timer->setSingleShot(true);
                        timer->setInterval(1000);
                        connect(timer, &QTimer::timeout,
                                [=, this]()
                        {
                            this->m_map.remove(identificationcode);
                            timer->deleteLater();
                        });
                        m_map.insert(identificationcode, timer);
                        timer->start();

                        data->setApplicationcode(applicationcode);
                        data->setIdentificationcode(identificationcode);
                        data->setDatetime(QDateTime::currentDateTime());
                        data->setSync(Rfiddata::KNotSynced);

                        QList<Rfiddata*> list;
                        list.append(data);
                        try {
                            PersistenceInterface *persister = qobject_cast<PersistenceInterface *>(RFIDMonitor::instance()->defaultService(ServiceType::KPersister));
                            Q_ASSERT(persister);
                            SynchronizationInterface *synchronizer = qobject_cast<SynchronizationInterface*>(RFIDMonitor::instance()->defaultService(ServiceType::KSynchronizer));
                            Q_ASSERT(synchronizer);

#ifdef CPP_11_ASYNC
                            /*C++11 std::async Version*/
                            std::function<void(const QList<Rfiddata *>&)> persistence = std::bind(&PersistenceInterface::insertObjectList, persister, std::placeholders::_1);
                            std::async(std::launch::async, persistence, list);
                            std::function<void()> synchronize = std::bind(&SynchronizationInterface::readyRead, synchronizer);
                            std::async(std::launch::async, synchronize);
#else
                            /*Qt Concurrent Version*/
                            QtConcurrent::run(persister, &PersistenceInterface::insertObjectList, list);
                            QtConcurrent::run(synchronizer, &SynchronizationInterface::readyRead);
#endif
                        } catch (std::exception &e) {
                            Logger::instance()->writeRecord(Logger::severity_level::fatal, m_module, Q_FUNC_INFO, e.what());
                        }
                    }
                }
            }
        }else{

//.........这里部分代码省略.........
开发者ID:CELTAB,项目名称:rfidmonitor,代码行数:101,代码来源:reader_rfm008b.cpp


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