日期:2014-05-16  浏览次数:20866 次

qt多线程中使用hide函数会使程序崩溃卡死
本帖最后由 suifenglianjiu 于 2013-07-13 21:09:30 编辑
本人用QT设计了一个多线程的程序:
    pthread_mutex_init(&run_lock,NULL);
    pthread_create(&th_gps,NULL,gps_receive,0);
    pthread_create(&th_velocity_alarm,NULL,velocity_alarm,0);
    pthread_create(&th_barrier,NULL,barrier_alarm,0);

    timer=new QTimer(this);
    timer->start(5000);
    connect(timer,SIGNAL(timeout()),this,SLOT(update()));
然后再设置一了个按钮,这个按钮点击以后会弹出一个Frame窗口,在窗口上进行一系列操作后我想让窗口隐藏,我用的是hide()函数,但每次一点击就使程序卡死,动都动不了。
但如果我不用多线程,一样的程序,使用hide函数,Frame窗口却能正确隐藏
这是什么原因啊,跟多线程有关系着没?求解!!
Qt 多线程 hide函数?

------解决方案--------------------
对于GUI的有关操作,需要在1个线程内进行。