add this to constructor of your ThreadRead QObject::connect(this, SIGNAL(finished()), this, SLOT(deleteLater()));
如果频繁点,干嘛每次都要delete再new ,这不是降低效率嘛。 如果你线程不做判断,一直在运行的话。你可以在button的响应槽里,加入判断 //ThreadRead *th_Read=new ThreadRead(); // 这个把它放到其它地方定义,不要每次 new 它 //然后通过线程的状态判断,没启动就去启动它 if(th_Read) { if ( !th_Read.isRunning()) { th_Read->start(); } } 如果你需要和线程互动,则可以在线程里加上标记,根据你在外部填入的值,执行不同的动作。
if(th_Read) { if ( !th_Read.isRunning()) { th_Read->start(); } }
16,216
社区成员
26,595
社区内容
加载中
试试用AI创作助手写篇文章吧