本文整理汇总了C++中QThread::quit方法的典型用法代码示例。如果您正苦于以下问题:C++ QThread::quit方法的具体用法?C++ QThread::quit怎么用?C++ QThread::quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QThread
的用法示例。
在下文中一共展示了QThread::quit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debuger_exec
DEBUGER_EXPORT int debuger_exec(int (*fn)(int, char**), void (*exit_fn)()) {
if (fn) {
debuger_thread_runner runner(fn, app_argc, app_argv);
debuger_thread_actor actor;
QThread child;
QObject::connect(&actor, SIGNAL(start()), &runner, SLOT(start()));
QObject::connect(&runner, SIGNAL(finished()), &actor, SLOT(finished()));
runner.moveToThread(&child);
child.start();
actor.start();
int ret = debuger::app->exec();
if (exit_fn)
exit_fn();
// ==== child join
child.quit();
child.wait();
return ret;
}
return debuger::app->exec();
}
示例2: handleResults
void ArchiveCA_Plugin::handleResults(indexes indexNew, int nbVal, QVector<double> TimerN, QVector<double> YValsN, QString backend)
{
//qDebug() << "in CA handle results" << nbVal << TimerN.count();
if(nbVal > 0) {
TimerN.resize(nbVal);
YValsN.resize(nbVal);
archiverCommon->updateCartesian(nbVal, indexNew, TimerN, YValsN, backend);
TimerN.resize(0);
YValsN.resize(0);
}
QList<QString> removeKeys;
removeKeys.clear();
QMap<QString, QThread *>::iterator j = listOfThreads.find(indexNew.key);
while (j !=listOfThreads.end() && j.key() == indexNew.key) {
QThread *tmpThread = (QThread*) j.value();
tmpThread->quit();
removeKeys.append(indexNew.key);
//qDebug() << tmpThread << "ca quit";
++j;
}
for(int i=0; i< removeKeys.count(); i++) {
listOfThreads.remove(removeKeys.at(i));
}
}
示例3: databaseThreaded
void tst_QDjango::databaseThreaded()
{
if (QDjango::database().databaseName() == QLatin1String(":memory:"))
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QSKIP("Threaded test cannot work with in-memory SQLite database.");
#else
QSKIP("Threaded test cannot work with in-memory SQLite database.", SkipAll);
#endif
QDjangoQuerySet<Author> qs;
QCOMPARE(qs.count(), 0);
QEventLoop loop;
Worker worker;
QThread workerThread;
// fire up worker
worker.moveToThread(&workerThread);
connect(&worker, SIGNAL(done()), &loop, SLOT(quit()));
workerThread.start();
QTimer::singleShot(0, &worker, SLOT(doIt()));
loop.exec();
// check database
QCOMPARE(qs.count(), 1);
// stop thread
workerThread.quit();
workerThread.wait();
}
示例4: main
int main(int argc, char* argv[])
{
#ifdef Q_WS_X11
QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
#endif
QGuiApplication app(argc,argv);
SettingsRef settings;
MainWindow *window;
int result;
app.setOrganizationName("libosmscout");
app.setOrganizationDomain("libosmscout.sf.net");
app.setApplicationName("OSMScout");
settings=new Settings();
//qRegisterMetaType<RenderMapRequest>();
qRegisterMetaType<DatabaseLoadedResponse>();
qmlRegisterType<MapWidget>("net.sf.libosmscout.map", 1, 0, "Map");
qmlRegisterType<Location>("net.sf.libosmscout.map", 1, 0, "Location");
qmlRegisterType<LocationListModel>("net.sf.libosmscout.map", 1, 0, "LocationListModel");
qmlRegisterType<RouteStep>("net.sf.libosmscout.map", 1, 0, "RouteStep");
qmlRegisterType<RoutingListModel>("net.sf.libosmscout.map", 1, 0, "RoutingListModel");
qmlRegisterSingletonType<Theme>("net.sf.libosmscout.map", 1, 0, "Theme", ThemeProvider);
QThread thread;
if (!DBThread::InitializeInstance()) {
std::cerr << "Cannot initialize DBThread" << std::endl;
}
DBThread* dbThread=DBThread::GetInstance();
window=new MainWindow(settings,
dbThread);
window->resize(480,800);
window->setResizeMode(QQuickView::SizeRootObjectToView);
dbThread->connect(&thread, SIGNAL(started()), SLOT(Initialize()));
dbThread->connect(&thread, SIGNAL(finished()), SLOT(Finalize()));
dbThread->moveToThread(&thread);
thread.start();
window->show();
result=app.exec();
delete window;
thread.quit();
thread.wait();
DBThread::FreeInstance();
return result;
}
示例5: stopDeviceThread
void LedDeviceWrapper::stopDeviceThread()
{
_ledDevice->switchOff();
QThread* oldThread = _ledDevice->thread();
delete _ledDevice; // fast desctruction
oldThread->quit(); // non blocking
}
示例6: 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;
}
示例7: exec
int ServerApp::exec()
{
QThread appThread;
m_impl->application.moveToThread(&appThread);
appThread.start();
m_impl->window.show();
// ... and run
// Qt event loop must be in the main thread
boost::thread orbThread(
boost::bind(&CORBA::ORB::run, m_impl->orb.in()));
int res = m_impl->app.exec();
appThread.quit();
appThread.wait();
m_impl->orb->shutdown(1);
orbThread.join();
delete m_impl;
m_impl = NULL;
return res;
}
示例8: main
int main(int argc, char* argv[])
{
#ifdef Q_WS_X11
QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
#endif
QGuiApplication app(argc,argv);
SettingsRef settings;
MainWindow *window;
int result;
app.setOrganizationName("libosmscout");
app.setOrganizationDomain("libosmscout.sf.net");
app.setApplicationName("OSMScout");
settings=std::make_shared<Settings>();
qRegisterMetaType<RenderMapRequest>();
qRegisterMetaType<DatabaseLoadedResponse>();
qRegisterMetaType<osmscout::TileRef>();
qmlRegisterType<MapWidget>("net.sf.libosmscout.map", 1, 0, "Map");
qmlRegisterType<Location>("net.sf.libosmscout.map", 1, 0, "Location");
qmlRegisterType<LocationListModel>("net.sf.libosmscout.map", 1, 0, "LocationListModel");
qmlRegisterType<FileIO, 1>("FileIO", 1, 0, "FileIO");
QThread thread;
if (!DBThread::InitializeInstance(/*settings*/)) {
std::cerr << "Cannot initialize DBThread" << std::endl;
}
DBThread* dbThread=DBThread::GetInstance();
window=new MainWindow(settings,
dbThread);
dbThread->connect(&thread, SIGNAL(started()), SLOT(Initialize()));
dbThread->connect(&thread, SIGNAL(finished()), SLOT(Finalize()));
dbThread->moveToThread(&thread);
thread.start();
result=app.exec();
delete window;
QString tmpStylesheet(dbThread->GetStylesheetFilename()+TMP_SUFFIX);
if(QFile::exists(tmpStylesheet)) {
QFile::remove(tmpStylesheet);
}
thread.quit();
thread.wait();
DBThread::FreeInstance();
return result;
}
示例9: calibrateVolume
void TSController::calibrateVolume(){
QSettings settings("settings.ini",QSettings::IniFormat);
QDialog d(this);
Ui::TSProgressDialog dui;
//d.setWindowFlags(Qt::SubWindow);
dui.setupUi(&d);
//controller->setWindowFlags(Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint|Qt::SubWindow);
d.setWindowTitle(tr("Предупреждение"));
dui.information->setText(tr("Идет подготовка..."));
dui.acceptButton->setVisible(false);
TSUsbDataReader *reader = new TSUsbDataReader();
QThread *thread = new QThread();
connect(thread,SIGNAL(started()),reader,SLOT(doWork()));
connect(reader,SIGNAL(done()),&d,SLOT(accept()));
connect(reader,SIGNAL(changeProgress(int)),dui.progressBar,SLOT(setValue(int)));
reader->setBuffer(curveBuffer);
reader->setReadingType(ReadForVolZer);
reader->moveToThread(thread);
thread->start();
/*connect(readerThread,SIGNAL(done()),&d,SLOT(accept()));
connect(readerThread,SIGNAL(changeProgress(int)),dui.progressBar,SLOT(setValue(int)));
readerThread->setReadingType(ReadForVolZer);
readerThread->startRead();*/
if(d.exec()==1){
settings.setValue("volZero",curveBuffer->volumeColibration());
dui.information->setText(tr("Подготовка завершена.\nНажмите ОК и качайте шприцем."));
dui.progressBar->setVisible(false);
dui.acceptButton->setVisible(true);
}
reader->stopRead();
Sleep(200);
thread->quit();
Sleep(200);
thread->disconnect(reader);
disconnect(&d,SLOT(accept()));
delete thread;
thread = NULL;
delete reader;
reader=NULL;
d.exec();
connect(&cPlotingTimer,SIGNAL(timeout()),this,SLOT(plotCalibration()));
_reader = new TSUsbDataReader();
_thread = new QThread();
connect(_thread,SIGNAL(started()),_reader,SLOT(doWork()));
connect(_reader,SIGNAL(done()),&d,SLOT(accept()));
connect(_reader,SIGNAL(changeProgress(int)),dui.progressBar,SLOT(setValue(int)));
_reader->setBuffer(curveBuffer);
_reader->setReadingType(ReadForVolVal);
_reader->moveToThread(_thread);
_thread->start();
cPlotingTimer.start(100);
}
示例10: main
int main(int argc, char* argv[])
{
#ifdef Q_WS_X11
QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
#endif
QGuiApplication app(argc,argv);
SettingsRef settings;
int result;
app.setOrganizationName("libosmscout");
app.setOrganizationDomain("libosmscout.sf.net");
app.setApplicationName("OSMScout");
qRegisterMetaType<RenderMapRequest>();
qRegisterMetaType<DatabaseLoadedResponse>();
qRegisterMetaType<osmscout::TileRef>();
qmlRegisterType<MapWidget>("net.sf.libosmscout.map", 1, 0, "Map");
qmlRegisterType<Location>("net.sf.libosmscout.map", 1, 0, "Location");
qmlRegisterType<LocationListModel>("net.sf.libosmscout.map", 1, 0, "LocationListModel");
qmlRegisterType<RouteStep>("net.sf.libosmscout.map", 1, 0, "RouteStep");
qmlRegisterType<RoutingListModel>("net.sf.libosmscout.map", 1, 0, "RoutingListModel");
qmlRegisterSingletonType<Theme>("net.sf.libosmscout.map", 1, 0, "Theme", ThemeProvider);
osmscout::log.Debug(true);
settings=std::make_shared<Settings>();
QThread thread;
if (!DBThread::InitializeInstance()) {
std::cerr << "Cannot initialize DBThread" << std::endl;
return 1;
}
DBThread* dbThread=DBThread::GetInstance();
dbThread->connect(&thread, SIGNAL(started()), SLOT(Initialize()));
dbThread->connect(&thread, SIGNAL(finished()), SLOT(Finalize()));
dbThread->moveToThread(&thread);
QQmlApplicationEngine window(QUrl("qrc:/qml/main.qml"));
thread.start();
result=app.exec();
thread.quit();
thread.wait();
DBThread::FreeInstance();
return result;
}
示例11:
AssignmentClient::~AssignmentClient() {
QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
// remove the NodeList from the DependencyManager
DependencyManager::destroy<NodeList>();
// ask the node thread to quit and wait until it is done
nodeThread->quit();
nodeThread->wait();
}
示例12: main
int main(int argc, char ** argv) {
QCoreApplication app{argc, argv};
QObject context;
QThread thread;
context.moveToThread(&thread);
thread.start();
onTimeout(1000, []{ qDebug() << "T+1s"; });
onTimeout(2000, &context, [&]{ qDebug() << "T+2s"; thread.quit(); });
QObject::connect(&thread, &QThread::finished, &app, &QCoreApplication::quit);
return app.exec();
}
示例13: syncAndRender
void QWinRTAbstractVideoRendererControl::syncAndRender()
{
qCDebug(lcMMVideoRender) << __FUNCTION__;
Q_D(QWinRTAbstractVideoRendererControl);
QThread *currentThread = QThread::currentThread();
const QMetaMethod present = staticMetaObject.method(staticMetaObject.indexOfMethod("present()"));
forever {
if (currentThread->isInterruptionRequested())
break;
{
CriticalSectionLocker lock(&d->mutex);
HRESULT hr;
if (d->dirtyState == TextureDirty) {
CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, d->format.frameWidth(), d->format.frameHeight(), 1, 1);
desc.BindFlags |= D3D11_BIND_RENDER_TARGET;
desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
hr = g->device->CreateTexture2D(&desc, NULL, d->texture.ReleaseAndGetAddressOf());
BREAK_IF_FAILED("Failed to get create video texture");
ComPtr<IDXGIResource> resource;
hr = d->texture.As(&resource);
BREAK_IF_FAILED("Failed to cast texture to resource");
hr = resource->GetSharedHandle(&d->shareHandle);
BREAK_IF_FAILED("Failed to get texture share handle");
d->dirtyState = SurfaceDirty;
}
hr = g->output->WaitForVBlank();
CONTINUE_IF_FAILED("Failed to wait for vertical blank");
bool success = false;
switch (d->blitMode) {
case DirectVideo:
success = render(d->texture.Get());
break;
case MediaFoundation:
success = dequeueFrame(&d->presentFrame);
break;
default:
success = false;
}
if (!success)
continue;
// Queue to the control's thread for presentation
present.invoke(this, Qt::QueuedConnection);
currentThread->eventDispatcher()->processEvents(QEventLoop::AllEvents);
}
}
// All done, exit render loop
currentThread->quit();
}
示例14: cleanupIdleThreads
void ThreadPoolWithSignals::cleanupIdleThreads()
{
// QMutexLocker l(&threadMutex);
while (idleThreads.count()>5)
{
QThread* t = *(idleThreads.begin());
idleThreads.remove(t);
allThreads.remove(t);
t->quit();
}
}
示例15: cleanupPrivateInstance
// cleans up the settings private instance. Should only be run once at closing down.
void cleanupPrivateInstance() {
// grab the thread before we nuke the instance
QThread* settingsManagerThread = privateInstance->thread();
// tell the private instance to clean itself up on its thread
privateInstance->deleteLater();
privateInstance = NULL;
// quit the settings manager thread and wait on it to make sure it's gone
settingsManagerThread->quit();
settingsManagerThread->wait();
}