{"id":17062137,"url":"https://github.com/recp/qt-dispatch","last_synced_at":"2026-04-16T13:32:42.286Z","repository":{"id":10523015,"uuid":"12713410","full_name":"recp/Qt-Dispatch","owner":"recp","description":null,"archived":false,"fork":false,"pushed_at":"2013-12-15T09:59:18.000Z","size":128,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-28T15:19:58.160Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/recp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-09T21:28:40.000Z","updated_at":"2018-09-28T15:04:11.000Z","dependencies_parsed_at":"2022-08-30T17:11:43.502Z","dependency_job_id":null,"html_url":"https://github.com/recp/Qt-Dispatch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2FQt-Dispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2FQt-Dispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2FQt-Dispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2FQt-Dispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recp","download_url":"https://codeload.github.com/recp/Qt-Dispatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245076162,"owners_count":20557045,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T10:49:18.680Z","updated_at":"2026-04-16T13:32:42.250Z","avatar_url":"https://github.com/recp.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Qt-Dispatch\n===========\n\nExecute block on the main thread or specified thread with Qt framework. \n\nNo required SIGNAL/SLOTs, no required QObject::connect...\n\nUse with functions or C++11 Lamdas \n\nFunctions\n------------\n\n```cpp\nstatic void q_dispatch_async_main(fnBlock block); // Execute on Main / UI thread.\nstatic void q_dispatch_async(QThread* thread, fnBlock block); // Execute on some thread.\n```\n\nSAMPLE USAGE\n------------\n\n```cpp\n\n#include \"qt_dispatch.h\"\n\n// Usage 1: Using with lambdas\n\n// This function called from non-ui/background thread.\nvoid MainWindow::handleSockData(void *obj) {\n  // This usage requires C++11 \n  q_dispatch_async_main([\u0026]() {\n     // Add widgets to window using ui object. \n     SomeWidget *widget = new SomeWidget();\n     ui-\u003esomeVLayout-\u003eaddWidget(widget);\n     \n     // check the thread id\n     const bool isGuiThread = QThread::currentThread() ==\n                                    QCoreApplication::instance()-\u003ethread();\n     qWarning() \u003c\u003c \"isGuiThread: \" \u003c\u003c isGuiThread; // true\n  });\n}\n\n// Usage 2: Using with functions\n\nvoid MainWindow::handleSockData(void *obj{\n  void somefunc();\n  q_dispatch_async_main(somefunc);\n}\n\nvoid somefunc() {\n  const bool isGuiThread = QThread::currentThread() ==\n                                    QCoreApplication::instance()-\u003ethread();\n  qWarning() \u003c\u003c \"isGuiThread: \" \u003c\u003c isGuiThread; // true\n}\n\n\n// Usage 3: Using with other threads\n\nvoid MainWindow::on_action1_triggered() {\n  QThread *newThread = new QThread();\n  newThread-\u003estart();\n\n  q_dispatch_async(newThread, []() {\n    const bool isGuiThread = QThread::currentThread() ==\n                                    QCoreApplication::instance()-\u003ethread();\n    qWarning() \u003c\u003c \"isGuiThread: \" \u003c\u003c isGuiThread; // false\n  });\n}\n```\n\nEnabling C++11 Compiler Support: Add these lines to your .pro file\n\n```\nCONFIG += c++11\nQMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7\nLIBS += -stdlib=libc++ -mmacosx-version-min=10.7\n```\n\n###Enjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecp%2Fqt-dispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecp%2Fqt-dispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecp%2Fqt-dispatch/lists"}