sdastagirmca
21st July 2010, 09:48
hi All,
i want to change my msleep seconds by QSlider.According to the value change in slider ,the seconds should be changed.
class MyThread :public QThread
{
Q_OBJECT
private:
bool m_bToSuspend;
QWaitCondition m_waitCondt;
public :
QMutex mutex;
QWaitCondition wcCondition;
int count,iSeconds;
MyThread()
{
count=0;
m_bToSuspend=false;
iSeconds=1000;
}
void run()
{
QMutex waitMutex;
//qDebug()<<"count : "<<count;
for (int i=0;i<count;)
{
msleep(iSeconds);
qDebug()<<iSeconds;
emit changeValue(i);
// pause the simulator
if (m_bToSuspend)
{
waitMutex.lock();
m_waitCondt.wait(&waitMutex);
waitMutex.unlock();
}
i+=3;
}
}
signals:
void changeValue(int i);
public slots:
void getCount (int pCount)
{
count=pCount;
}
void suspend();
void startThread();
void getTimer(int pval)
{
iSeconds=pval*100;
}
};
In this getTimer() slot is used by the slider control.
connect(slider,SIGNAL(valuchanged(int)),thread,SLO T(getTimer()));
The thread is started after creating a instance of the class MyThread;
i want to change my msleep seconds by QSlider.According to the value change in slider ,the seconds should be changed.
class MyThread :public QThread
{
Q_OBJECT
private:
bool m_bToSuspend;
QWaitCondition m_waitCondt;
public :
QMutex mutex;
QWaitCondition wcCondition;
int count,iSeconds;
MyThread()
{
count=0;
m_bToSuspend=false;
iSeconds=1000;
}
void run()
{
QMutex waitMutex;
//qDebug()<<"count : "<<count;
for (int i=0;i<count;)
{
msleep(iSeconds);
qDebug()<<iSeconds;
emit changeValue(i);
// pause the simulator
if (m_bToSuspend)
{
waitMutex.lock();
m_waitCondt.wait(&waitMutex);
waitMutex.unlock();
}
i+=3;
}
}
signals:
void changeValue(int i);
public slots:
void getCount (int pCount)
{
count=pCount;
}
void suspend();
void startThread();
void getTimer(int pval)
{
iSeconds=pval*100;
}
};
In this getTimer() slot is used by the slider control.
connect(slider,SIGNAL(valuchanged(int)),thread,SLO T(getTimer()));
The thread is started after creating a instance of the class MyThread;