惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
T
Tailwind CSS Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
N
News and Events Feed by Topic
月光博客
月光博客
TaoSecurity Blog
TaoSecurity Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
N
News | PayPal Newsroom
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Privacy & Cybersecurity Law Blog
GbyAI
GbyAI
K
Kaspersky official blog
WordPress大学
WordPress大学
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 叶小钗
W
WeLiveSecurity
Jina AI
Jina AI
The Cloudflare Blog
Project Zero
Project Zero
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
L
LangChain Blog
Forbes - Security
Forbes - Security
PCI Perspectives
PCI Perspectives
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
博客园 - 【当耐特】
H
Heimdal Security Blog
A
About on SuperTechFans
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
云风的 BLOG
云风的 BLOG
Spread Privacy
Spread Privacy
L
LINUX DO - 最新话题
L
Lohrmann on Cybersecurity
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
Intezer
Martin Fowler
Martin Fowler
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint

Qt

撸了一个面向 Qt Widgets 的 Fluent 风格组件库 - V2EX 请问一下大家用 ai 做 qt 应用的时候有什么 skill 或者方法改进 ui 吗? qt 新手求助: No documents matching 'ui_mainwindow.h' could be found - V2EX 请教几个 qt6, macos 打包遇到依赖问题。 - V2EX 新建一个 qt 项目,运行时,底下应用程序输出 1127, FromFilemap - V2EX Qt5 托盘菜单右击时的异常 - V2EX 有没有什么工具可以美化 qt 界面的? - V2EX Qt 有什么不错的第三方控件库吗? 寻求帮助!在 qt creator 里面创建 quick 项目失败,找不到原因。 - V2EX 关于 QT 中通过信号与槽的方式启动子线程的问题。 - V2EX 寻找一起开发这个开源项目的人, qt c++的,信息收藏、Kindle/微信读书/豆瓣阅读笔记管理 - V2EX 使用 Qt 做的软件界面太丑怎么办?有没有什么美工插件或者入门教程 - V2EX 有哪位大佬对修改 3DSlicer 或者开发插件有经验? - V2EX 如何正确安装 QT? - V2EX 请教 qt svg 打包后无法显示问题。 如何在 QT 中的多个级别的窗口之间传输消息 - V2EX 在 Qt 中控件同时使用智能指针和父子关系,会有二次删除风险吗? - V2EX qt5 中文乱码问题怎么解决? - V2EX 现在写 Qt 的主流 IDE 工具是什么? - V2EX 请问多线程之间是如何协调配合的? - V2EX QSerialPort 如何实现同一个串口设备命令做出不同操作? qt creator 插件开发问题请教 - V2EX 求助一个读硬盘序列号的问题 - V2EX 关于 Qt6.6.0 无法设置程序图标的问题 - V2EX 求助,如何编译 openwrt 的时候加入 qt6 - V2EX 为什么 Qt Creator 界面如此丑陋 - V2EX 大家了解 Qt 和 qt-creator 的开源协议吗?基于它,可以写闭源商用的软件吗? 求助,使用 CLion 开发 Qt,创建了 UI 类不会使用 - V2EX mac 下的 Qt/C++应用,通过 url scheme 唤起时,如何获取到唤起的链接? - V2EX Qt 中的 `QFontMetrics.boundingRect()` 算出来的文本长度有时候会不对,应该如何处理。 - V2EX 求助: Qt 开发 android 程序遇到编译不通过 Qt 里的 Qprocess 怎么完全 kill 一个 mpi 程序 - V2EX 请教一个 qt graphicsview 优化问题 - V2EX 求指点 QtWidget 程序如何改善 Wayland 下的兼容性? - V2EX Qt Quick 应用拖动的时候卡顿 - V2EX pro 文件中如何设置编译完后能运行指定的批处理文件? - V2EX 请教关于 Qt 事件的传播顺序的问题 - V2EX PyQt 交流群成立了,欢迎各位大佬加入 - V2EX 现在还建议提前学习 Qt 框架吗? - V2EX 正式环境下,如何分析 qt 程序的内存泄露? - V2EX 求教 : Qt 两个 QWidget 叠加显示问题 - V2EX 在自学 qt,因为习惯问题用的是 clion,标准 qt 工程没问题,但是想写 qt 插件, cmake 打出来的 dll 文件宿主不识别,请问有用 clion 开发过 qt6 插件的朋友么,求指导或者资料帮助 - V2EX QUdpSocket bind 特定的本地 ip,无法发送数据? - V2EX QT 界面如何实现随电脑百分比放大、缩小 - V2EX 希望找一位精通 QT 者:合作一短期项目,预计一月内完成。 - V2EX 不太理解 Qt 多线程 Wait Conditions Example 为什么 ListView 没有随窗口大小自适应缩放? - V2EX 可以让 qmake 多项目并行编译吗? - V2EX pro 项目文件中,如何判断编译器?
关于 QT(C++)通过继承 QObject 的方法实现多线程,子线程调用失效。 - V2EX
h3xz · 2024-07-08 · via Qt
class MyThread : public QObject{
	Q_OBJECT
	void work(){	 
    	qDebug()<<"MyThread::work() thread id: "<<QThread::currentThreadId()<<"\n";	
    }
}
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    qDebug()<<"main thread id: "<<QThread::currentThreadId()<<"\n";
    QThread* subThread = new QThread;
    MyThread* my_thread = new MyThread;
    my_thread->moveToThread(thread1);
    my_thread->start();	
    
    qDebug()<<"00000000";
    my_thread->work();
    
    connect(ui->pushButton, &QPushButton::clicked, my_thread, &MyThread::work);
    connect(ui->pushButton, &QPushButton::clicked, this, [=]{
        qDebug()<<"11111111";
    	my_thread->work();
    });
    connect(ui->pushButton, &QPushButton::clicked, my_thread, [=]{
		qDebug()<<"22222222";
        my_thread->work();
    });
}

程序执行结果:

main thread id:  0x1a70 

00000000
MyThread::work1() thread id:  0x1a70 

11111111
MyThread::work1() thread id:  0x1a70 

MyThread::work1() thread id:  0x698 

22222222
MyThread::work1() thread id:  0x698 

请问为何在主窗口中直接调用 my_thread 和
connect(ui->pushButton, &QPushButton::clicked, this, [=]{ my_thread->work(); });都是在主线程中执行,而其他两种调用方式就能正确在子线程中执行?