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


C++ QThread::isRunning方法代码示例

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


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

示例1: quit

bool CuteNews::quit() {
    if (m_connection) {
        m_connection->close();
    }
    
    QThread *dbThread = DBConnection::asynchronousThread();

    if ((dbThread) && (dbThread != QThread::currentThread())) {
        if (dbThread->isRunning()) {
            Logger::log("CuteNews::quit(). Shutting down the database thread", Logger::LowVerbosity);
            connect(dbThread, SIGNAL(finished()), this, SLOT(quit()), Qt::UniqueConnection);
            dbThread->quit();
            return false;
        }
    }
        
    const int expiryDays = Settings::readArticleExpiry();
    
    if (expiryDays > -1) {
        uint expiryDate = QDateTime::currentDateTime().toTime_t();

        if (expiryDays > 0) {
            expiryDate -= expiryDays * 86400;
        }
        
        Logger::log("CuteNews::quit(). Deleting read articles older than "
                    + QDateTime::fromTime_t(expiryDate).toString(Qt::ISODate));
        DBConnection(false).deleteExpiredArticles(expiryDate);
    }
    
    Transfers::instance()->save();
    Logger::log("CuteNews::quit(). Quitting the application", Logger::LowVerbosity);
    QCoreApplication::quit();
    return true;
}
开发者ID:marxoft,项目名称:cutenews,代码行数:35,代码来源:cutenews.cpp

示例2: main

int main(int argc, char** argv) {
    auto worker = std::make_shared<WorkerThread>();
    auto options = parse_options(argc,argv);
    set_options(*worker,options);

    auto publishers = create_publishers(*worker,options);

    // gui mode
    if (!options.count("novis")){
#ifdef ENABLE_QT5
        qRegisterMetaType<GazeHypsPtr>();
        qRegisterMetaType<std::string>();
        QApplication app(argc, argv);
        GazerGui gui;
        set_options(gui,options);
        WorkerAdapter gazer(worker);
        QThread thread;
        gazer.moveToThread(&thread);

        QObject::connect(&app, SIGNAL(lastWindowClosed()), &gazer, SLOT(stop()));
        QObject::connect(&gazer, SIGNAL(finished()), &thread, SLOT(quit()));
        QObject::connect(&gazer, SIGNAL(imageProcessed(GazeHypsPtr)), &gui,
                         SLOT(displayGazehyps(GazeHypsPtr)), Qt::QueuedConnection);
        QObject::connect(&gazer, SIGNAL(statusmsg(std::string)), &gui, SLOT(setStatusmsg(std::string)));
        QObject::connect(&thread, SIGNAL(started()), &gazer, SLOT(process()));
        QObject::connect(&gui, SIGNAL(horizGazeToleranceChanged(double)), &gazer, SLOT(setHorizGazeTolerance(double)));
        QObject::connect(&gui, SIGNAL(verticalGazeToleranceChanged(double)), &gazer, SLOT(setVerticalGazeTolerance(double)));
        QObject::connect(&gui, SIGNAL(smoothingChanged(bool)), &gazer, SLOT(setSmoothing(bool)));
        if (!options.count("noquit")) {
            QObject::connect(&gazer, SIGNAL(finished()), &app, SLOT(quit()));
        }

        gui.show();
        thread.start();
        auto result = app.exec();
        //process events after event loop terminates allowing unfinished threads to send signals
        while (thread.isRunning()) {
            thread.wait(10);
            QCoreApplication::processEvents();
        }
        return result;
#else
        cerr << "Appplication build without qt. Assuming --novis" << std::endl;
#endif
    }
开发者ID:vrichter,项目名称:gazetool,代码行数:45,代码来源:main.cpp

示例3: edit

void sshsocket::edit()
{
    QTimer *timer = servers->at(index)->getTimer() ;
    if (timer != NULL)
    {
        if (timer->isActive())
        {
            timer->stop() ;
            delete timer ;
        }
    }

    QThread *thread = (QThread*)host->getThread() ;
    if (thread != NULL)
    {
        if (thread->isRunning())
        {
            thread->exit();
        }
    }
    servers->replace(index, host);
    model->new_updt(index);
}
开发者ID:kesrut,项目名称:ServerMonitorN9,代码行数:23,代码来源:sshsocket.cpp

示例4: QWidget

SkpSocketTestWidget::SkpSocketTestWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SkpSocketTestWidget),
    m_writeSize(0),
    m_readSize(0),
    m_sec(0),
    m_readavgSize(0),
    m_writavgeSize(0),

    m_connectNumber(0),
    m_realConnect(0),
    m_closeNumber(0),
    m_errorConnect(0),
    m_max(0),
    m_isStart(false),
    m_autoConnectNumber(0),
    m_showPrintNumber(0)
{
    ui->setupUi(this);

    //qDebug() << "main ID" << (qint64)QThread::currentThreadId();
    m_autoConnectNumber = 100;
    m_showPrintNumber = 1000;
    g_ShowPrintNumber = m_showPrintNumber;
    ui->autoconnect_lineEdit->setText(QString::number(m_autoConnectNumber));
    ui->showPrint_lineEdit->setText(QString::number(m_showPrintNumber));

    connect(&m_timer, SIGNAL(timeout()), this, SLOT(skp_on_timer_socket()));

    connect(ui->startTimer, SIGNAL(clicked()), this, SLOT(skp_on_timeout_start()));
    connect(ui->stopTimer, SIGNAL(clicked()), this, SLOT(skp_on_timeout_stop()));
    connect(ui->timerOnce, SIGNAL(clicked()), this, SLOT(skp_on_timer_socket_once()));

    connect(ui->connectSocket, SIGNAL(clicked()), this, SLOT(skp_on_simple_socket()));
    connect(ui->socketSend, SIGNAL(clicked()), this, SLOT(skp_on_simple_send()));
    connect(ui->socketRecv, SIGNAL(clicked()), this, SLOT(skp_on_simple_recv()));
    connect(ui->socketClose, SIGNAL(clicked()), this, SLOT(skp_on_simple_close()));

    connect(ui->protocolConn, SIGNAL(clicked()), this, SLOT(skp_on_simple_protocol()));
    connect(ui->protocolConnClose, SIGNAL(clicked()), this, SLOT(skp_on_simple_protocol_close()));

    connect(&m_statisticsTimer, SIGNAL(timeout()), this, SLOT(skp_on_print()));
    ///yefy___
    //m_statisticsTimer.start(5000);

    connect(&m_taskTimer, SIGNAL(timeout()), this, SLOT(skp_on_socket_task_start()));
    connect(ui->timerTaskStart, SIGNAL(clicked()), this, SLOT(skp_on_timer_task_start()));
    connect(ui->onceSocketTaskStart, SIGNAL(clicked()), this, SLOT(skp_on_socket_task_start()));
    connect(ui->ok_pushButton, SIGNAL(clicked()), this, SLOT(skp_on_socket_conf()));

    for(int i = 0; i < THREAD_NUMBER; i++) {
        QThread *thread = new QThread();
        m_threadList.push_back(thread);
        thread->start();
        while(!thread->isRunning()) {
            ;
        }

        SkpTcpSocketTask *tcpSocketTask = new SkpTcpSocketTask();
        tcpSocketTask->moveToThread(thread);
        connect(this, SIGNAL(skp_sig_create_socket()), tcpSocketTask, SLOT(skpOnCreateSocket()));
        connect(tcpSocketTask, SIGNAL(skp_sig_connect()), this, SLOT(skp_on_connect()));
        connect(tcpSocketTask, SIGNAL(skp_sig_quit(qint64, qint64, qint64, qint64)), this, SLOT(skp_on_quit(qint64, qint64, qint64, qint64)));
        connect(tcpSocketTask, SIGNAL(skp_sig_socket_quit(qint64, qint64, qint64, qint64)), this, SLOT(skp_on_socket_quit(qint64, qint64, qint64, qint64)));

    }
}
开发者ID:yefy,项目名称:skp,代码行数:67,代码来源:skp_socket_test_widget.cpp

示例5: Callback_UpdateInterface

// this routine will be called now every 10 seconds to update the cartesianplot
// however when many data it may take much longer, then  suppress any new request
void ArchiveCA_Plugin::Callback_UpdateInterface( QMap<QString, indexes> listOfIndexes)
{
    int nbVal;

    precision = 5;

    // Index name
    stdString index_name =  "/gfa/archiver-data/archive_PRO_ST/index";

    //qDebug() << "====================== ArchiveCA_Plugin::Callback_UpdateInterface";

    QMap<QString, indexes>::const_iterator i = listOfIndexes.constBegin();

    while (i != listOfIndexes.constEnd()) {
        QThread *tmpThread = (QThread *) 0;
        indexes indexNew = i.value();
        //qDebug() << i.key() << ": " << indexNew.indexX << indexNew.indexY << indexNew.pv << indexNew.w << endl;

        nbVal = 0;

        QMap<QString, QThread *>::iterator j = listOfThreads.find(indexNew.key);
        while (j !=listOfThreads.end() && j.key() == indexNew.key) {
            tmpThread = (QThread *) j.value();
            ++j;
        }

        //qDebug() << "tmpThread" << tmpThread;

        if((tmpThread != (QThread *) 0) && tmpThread->isRunning()) {
            //qDebug() << "workerthread is running" << tmpThread->isRunning();
        } else {

            // Get Index name if specified for this widget
            if(caCartesianPlot* w = qobject_cast<caCartesianPlot *>((QWidget*) indexNew.w)) {
                QVariant var = w->property("archiverIndex");
                if(!var.isNull()) {
                    QString indexName = var.toString();
                    index_name = qasc(indexName);
                } else if(indexNew.init){
                    QString mess("ArchiveCA plugin -- no archiverIndex defined as dynamic property in widget "  + w->objectName() + ", defaulting to /gfa/archiver-data/archive_PRO_ST/index");
                    if(messagewindowP != (MessageWindow *) 0) messagewindowP->postMsgEvent(QtWarningMsg, (char*) qasc(mess));
                }
            }

            WorkerCA *worker = new WorkerCA;
            QThread *tmpThread = new QThread;
            listOfThreads.insert(i.key(), tmpThread);
            worker->moveToThread(tmpThread);
            connect(tmpThread, SIGNAL(finished()), worker, SLOT(workerFinish()));
            connect(tmpThread, SIGNAL(finished()), tmpThread, SLOT(deleteLater()) );
            connect(this, SIGNAL(operate( QWidget *, indexes, const stdString)), worker,
                    SLOT(getFromArchive(QWidget *, indexes, stdString)));
            connect(worker, SIGNAL(resultReady(indexes, int, QVector<double>, QVector<double>, QString)), this,
                    SLOT(handleResults(indexes, int, QVector<double>, QVector<double>, QString)));
            tmpThread->start();

            //qDebug() << "CA emit operate";
            emit operate((QWidget *) messagewindowP ,indexNew, index_name);
        }
        ++i;
    }
}
开发者ID:caqtdm,项目名称:caqtdm,代码行数:64,代码来源:archiveCA_plugin.cpp


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