[Qt-interest] why terminated () or finsished () signals are not emitted when run() is finished.

Santhosh Y santhosh at softjin.com
Thu Sep 3 09:19:05 CEST 2009


Hi,

Please find below the implementation of Thread1 class a sub class of 
QThread.

The problem is after run () is finished , the signal is not emitted that 
saying thread is finished ()  or terminated ().

Please tell me what could be the problem here. I have connected the 
above signals in the class where I created thread.



#include <QThread>
#include <QtGui>
#include <iostream>

class Thread1 : public QThread
{
    Q_OBJECT

    public:
        Thread1 (QObject* p = 0);

    protected:
        void run ();

    signals:
        void itemCreated (QTableWidgetItem*, int, int);
};

#include "thread1.h"
Thread1 ::Thread1 (QObject* parent) : QThread (parent)
{
}

void
Thread1::run ()
{
    std::cout << "Started Population in Worker Thread " << std::endl;
    for (int i=0; i<40000; i++) {
        for (int j=0; j<4; j++) {
            emit itemCreated (new QTableWidgetItem(QString("Item %1 of 
%2").arg(i).arg(j)), i, j);
        }
    }
    std::cout << "End of  Population in Worker Thread " << std::endl;
}

-- 
----------------------------------------------------
Y Santhosh Kumar
Senior Software Engineer
SoftJin Technologies Private Limited
Unit No. 102, Mobius Tower,
I Floor, SJR I - Park,
EPIP, White Field,
Bangalore - 560066, India
U : www.softjin.com
E : santhosh at softjin.com
T : +91-80-41779999
M : +91-9740535265
----------------------------------------------------



Business Disclaimer
____________________________________________________________
This e-mail message and any files transmitted with it are intended solely
for  the use  of the  individual or entity  to which they  are  addressed. It
may  contain confidential,  proprietary or legally  privileged  information.
If  you  are  not  the  intended recipient please be advised that you have
received  this  message in error and any use is strictly prohibited. Please
immediately  delete it  and all copies of it from your system, destroy any
hard  copies  of  it and  notify  the  sender  by return mail. You must not,
directly or indirectly, use,  disclose,  distribute, print, or copy any part of
this message if you are not the intended recipient.
___________________________________________________________





More information about the Qt-interest-old mailing list