[Qt-interest] Timer objects conflicting

Yuvaraj R yuvaraj at ongobiz.com
Thu Aug 13 06:18:08 CEST 2009


Thanks Alex

  I don't have idea to switch timer values.
 Can you provide me a sample code ?

Thanks

Yuvaraj R

On Thu, Aug 13, 2009 at 7:04 AM, Malyushytsky, Alex <alex at wai.com> wrote:

> Thiago is right about static variable initialization and since your code
> mostly likely assumes that initial count should be 0,
> it is mostly likely not a problem here. It still might be a problem in
> other cases. I can only guess.
> I believe it is preferable to initialize static variable of the basic types
> (no constructors) even if it should be initialized to 0.
> This will clearly state for the person reviewing your code that you did not
> forget to do it.
> Comment can be used to get the same effect, but "= 0" is shorter.
> This is more related to the style and I would not probably mentioned this,
> if code posted was not so hard to read due to lack indentation already.
>
>
> Back to the problem.
> As it was pointed already by John, the "conflict" does not explain the
> problem.
>
> More of that, it is not clear what was intended to do.
> You explanation does not provide information what you are trying to
> achieve.
> It gives description how you are doing it.
>
> Since there are endless possibilities "What" you want to achieve it is
> tough to help you.
>
> For example if you wanted to show time passed from the click on the last
> button,
> The only single timer supposed to be running at any time.
> You have to stop previously running timer (if any), create a new one and
> change data to be displayed.
>
> If you have parallel processes running, timers represents each process and
> click of the specific button just supposed to switching the data displayed
> into specific control, you do need multiple timers.
> But only one timer at a time supposed to display the data, the one
> associated with specific process/button.
>
>
> Regards,
>   Alex
>
>
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:
> qt-interest-bounces at trolltech.com] On Behalf Of John McClurkin
> Sent: Wednesday, August 12, 2009 5:30 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Timer objects conflicting
>
> 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
> >
> >
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> "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."
>
>  _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090813/16a9c3f6/attachment.html 


More information about the Qt-interest-old mailing list