[Qt-interest] Timer objects conflicting
Malyushytsky, Alex
alex at wai.com
Wed Aug 12 01:25:23 CEST 2009
I am not sure I followed what you were trying to achieve.
I could assume something, based on your explanation, but if you want correct answer you need to ask correct question.
What is worth "objects are conflicting.. " gives no explanation of the problem you are facing.
Code provided does not give sufficient details to understand it.
It might be a good idea to spend more formulating question if you want help.
The only thing I can say right now:
- static int count; is not initialized
- time[count] = new QTimer; may create a problem depending on the container you are using.
Regards,
Alex
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Yuvaraj R
Sent: Tuesday, August 11, 2009 1:30 PM
To: qt-interest
Subject: [Qt-interest] Timer objects conflicting
Hi All
I have 10 items in list view.. Each widget containing the push button and label..
when push button is clicked the Timer is running ..suppose if click the first item push button timer value is display at label..After some times again i am clicking second push button... this item value also i have to display..
whenever user clicking the button, new object will be creating for QTimer..Here my problem is objects are conflicting..
My code is
void Form::get_timer(int id)
{
static int count;
qDebug() << "yuvaraj";
time[count] = new QTimer;
time[count]->start(1000);
QObject::connect(time[count],SIGNAL(timeout()),this,SLOT(run_timer()));
count++;
}
void Form::run_timer()
{
qDebug() << "yuvaraj 1";
QString time_count;
if(b==59 )
{
b=0;
a++;
}
if(a<10 && b<10 )
{
time_count = QString(QString::number(0)+QString::number(a) + ":"+QString::number(0)+QString::number(b));
}
if(a<10 && b >=10)
{
time_count = QString(QString::number(0)+QString::number(a) + ":"+QString::number(b));
}
if(a>=10 && b <10)
{
time_count = QString(QString::number(a) + ":"+QString::number(0)+QString::number(b));
}
if(a>=10 && b>=10)
{
time_count = QString(QString::number(0)+QString::number(a) + ":"+QString::number(b));
}
b++;
emit send_timer(count,time_count);
}
// slot for send_timer signal
void MainWindow:: get_timer(int item,QString str)
{
qDebug() << "yuvaraj" << str << item;
for(int i=0;i<list.size();i++)
{
if(i == list_item_id[item])
{
list.at(i)->m_ui->set_time->setText(str);
}
}
Please help me ,how do avoid the object conflicting
Thanks
Yuvaraj R
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
More information about the Qt-interest-old
mailing list