[Qt-interest] Timer objects conflicting
John McClurkin
jwm at nei.nih.gov
Wed Aug 12 14:30:02 CEST 2009
Yuvaraj R wrote:
> Alex
>
> I am explaining my problem here..
>
>
> I am creating new object for Timer .whenever i am clicking the push
> button .I have set the timer timer interval 1000 sec..
>
> If timeout signal is emitted it will run_timer slot..
>
> Here i am counting the seconds and send to my main window...
>
>
> What my thing is ,when i am creating the second object for timer,it is
> conflicting with object 1..
Your statement is still not helpful because you don't describe what the
conflict is. So, I'll try with a couple of questions. 1) What happens
when you just click push button 1? 2) What happens when you click push
button 1 then click push button 2? 3)How is this different from what you
want to happen?
>
> And more thing.. How come i know,which object is emitting the timeout signal
You can use the sender() function in the run_timer slot. See the Qt
documentation.
>
>
>
> Thanks
>
> Yuvaraj R
>
> On Wed, Aug 12, 2009 at 4:55 AM, Malyushytsky, Alex <alex at wai.com
> <mailto:alex at wai.com>> wrote:
>
> 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>
> [mailto: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 <http://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."
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
More information about the Qt-interest-old
mailing list