[Qt-interest] Timer objects conflicting
Yuvaraj R
yuvaraj at ongobiz.com
Thu Aug 13 16:52:48 CEST 2009
i have to increment the timer value separetly according to the buttons
1) click first button _________ start timer __________Display value( don't
stop ,if another buttons pressed means)
1) click secondbutton _________ start timer __________Display value(don't
show first button timer value)
when i am clicking the same button again,the corresponding timer will be
stoping.
How do set this senario
Thanks
Yuvaraj R
On Thu, Aug 13, 2009 at 7:55 PM, Mikhail Veygman <mveygman at gmail.com> wrote:
> It's Mikhail.
>
> If you need to time the buttons separately and need to know how much
> time the timer was active set a second list of values that will save
> that amount. First click will set the flag and start incrementing,
> second click will clear the flag and stop incrementing.
>
> If the first suggestion doesn't work for you try the second.
> -
> Regards,
>
> Mikhail Veygman
>
>
> -----Original Message-----
> From: Yuvaraj R <yuvaraj at ongobiz.com>
> To: Mikhail Veygman <mveygman at gmail.com>
> Cc: Malyushytsky, Alex <alex at wai.com>, qt-interest at trolltech.com
> <qt-interest at trolltech.com>
> Subject: Re: [Qt-interest] Timer objects conflicting
> Date: Thu, 13 Aug 2009 19:06:05 +0530
>
> Veygman
>
> AS per your first suggestion,
>
>
> ok , i am use single timer. if i someting upadated in object.,i set the
> flag ..
>
> But ,i need two buttons timer value separately..That's why i am creating
> new objects..
>
> any other idea ?
>
>
> Thanks
>
> Yuvaraj R
>
> On Thu, Aug 13, 2009 at 6:12 PM, Mikhail Veygman <mveygman at gmail.com>
> wrote:
> Yuvaraj,
>
> As Alex has stated the "conflict" doesn't explain the problem
> you are
> having and further doesn't specify the symptoms of the problem,
> which
> are needed.
>
> Looking at the code, however, I think you need to change the
> design of
> your application the reason being is: I would assume that you
> have only
> one instance of the Form class and all the timers are created
> through it
> so you are calling the same slot in the same object, so my
> suggestion
> for you would be 1 of the 2 things:
>
> 1. Use a single timer and just have a list of flags on whether
> something needs to be updated within the object and then update
> it based
> on the flag being set to true.
>
> 2. Break up data handling into separate objects and create the
> timer
> within the object so you are not attempting to update parameters
> within
> the same object.
>
> -
> Regards,
>
> Mikhail Veygman
>
>
> -----Original Message-----
> From: Malyushytsky, Alex <alex at wai.com>
> To: qt-interest at trolltech.com <qt-interest at trolltech.com>
> Subject: Re: [Qt-interest] Timer objects conflicting
>
>
> Date: Wed, 12 Aug 2009 18:34:42 -0700
>
> 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
>
> _______________________________________________
> 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/ada94d16/attachment.html
More information about the Qt-interest-old
mailing list