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


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

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


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

示例1: init

void WUManager::init()
{
    sendRequest();

    QThread* workHorse = new QThread(this);
    QTimer* timer = new QTimer(0);
    QEventLoop* loop = new QEventLoop();

    timer->setInterval(900000);    // every hour read weather data
    timer->moveToThread(workHorse);
    connect(this,  SIGNAL(replyProcessed()), loop, SLOT(quit()) );
    connect(timer, SIGNAL(timeout()), this, SLOT(sendRequest()));
    connect(workHorse, SIGNAL(started()), timer, SLOT(start()));
    workHorse->start();
    loop->exec();

    QThread* workHorseSensors = new QThread(this);
    QTimer* timerSensors = new QTimer(0);

    timerSensors->setInterval(1000);
    timerSensors->moveToThread(workHorse);
    connect(timerSensors, SIGNAL(timeout()), this, SLOT(readSensors()));
    connect(workHorseSensors, SIGNAL(started()), timerSensors, SLOT(start()));
    workHorseSensors->start();
}
开发者ID:mpawlowski7,项目名称:WeatherStation,代码行数:25,代码来源:WUManager.cpp

示例2: QObject

VOIP::VOIP(QObject* p) : QObject(p), speex(SAMPLE_RATE)
{
    qRegisterMetaType<ALshortVector >();
    rec = new Recorder(SAMPLE_RATE, this);
    rec->startRecord();
    connect(rec, SIGNAL(readyRead(ALshortVector)), &speex, SLOT(encode(ALshortVector)), Qt::QueuedConnection);
    connect(&speex, SIGNAL(encoded(QByteArray)), this, SLOT(send(QByteArray)), Qt::QueuedConnection);

    QTimer* updateT = new QTimer;
    connect(updateT, SIGNAL(timeout()), this, SLOT(update()));
    updateT->start(1000);

    udpSocket = new QUdpSocket(this);
    m_port=VOIP_DEFAULT_PORT;

    m_receiver=0;
    m_sound=new Sound(SAMPLE_RATE);
    m_sound->play();

    dataUp = 0;
    setVolume(50);
    m_enabled=true;
    setQuality(4);

    updateT->moveToThread(&m_thread);
    moveToThread(&m_thread);
    m_thread.start();
}
开发者ID:DPSLynix,项目名称:celendel,代码行数:28,代码来源:VOIP.cpp

示例3: run

void Time::run()
{
    int interval=5000;
    QThread* somethread = new QThread(this);
    QTimer *timer = new QTimer();

    connect(timer, SIGNAL(timeout()), this, SLOT(VerifPing()));
     timer->start();
     timer->setInterval(interval);
     timer->moveToThread(somethread);
     somethread->start();
}
开发者ID:Enthraax,项目名称:depot_test_Pierre,代码行数:12,代码来源:time.cpp

示例4: sigSetup

QCVWidget::QCVWidget(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::QCVWidget)
{
    ui->setupUi(this);
    //setup();
	thread = new QThread();
	RGBCamera *worker = new RGBCamera();
	QTimer *workerTrigger = new QTimer();
	workerTrigger->setInterval(1);

	connect(workerTrigger, SIGNAL(timeout()), worker, SLOT(slotGrabFrame()));
	connect(this, SIGNAL(sigSetup(int)), worker, SLOT(slotSetup(int)));
	connect(worker, SIGNAL(sigFrame(QImage)), this, SLOT(slotFrame(QImage)));

	workerTrigger->start();
	worker->moveToThread(thread);
	workerTrigger->moveToThread(thread);
	thread->start();

	emit sigSetup(0);
}
开发者ID:BoubekeurAis,项目名称:WebCamCvQt,代码行数:22,代码来源:qcvwidget.cpp


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