PDA

View Full Version : QObject::startTimer: QTimer cannot have a negative interval



iswaryasenthilkumar
12th February 2015, 11:39
am using Qtimer timeout concept i having 60000 and 10000 seconds .60000 seconds(1 minute) it displays the one image and 10000 seconds(10 seconds) displays the another images..i getting error
QObject::startTimer: QTimer cannot have a negative interval when timer reaches 60000 seconds..can any one give me suggestion for this:confused:
Thanks for advance :)

wysota
12th February 2015, 12:39
What is the datatype you are using to store your "60000 seconds" value? You are aware that 60000 seconds is not one minute, right? So are we talkig about seconds or miliseconds here? What datatypes are you using for those values?

iswaryasenthilkumar
13th February 2015, 04:37
am having one text file inside that
60000
10000
after reading this file i assigned to variables..and pass these variables to timeout ();
i want to display one images for first images for 60 seconds..and second image for 10 seconds.

wysota
13th February 2015, 06:41
after reading this file i assigned to variables
What variables? How did you do it? Show the code.

iswaryasenthilkumar
13th February 2015, 10:23
code:


#define configpath "/digital_images/config"
void Widget::readconfigfile()
{
dir.cd(configpath);
QFile file1;
QString configfile="DI_config.txt";
file1.setFileName(dir.absoluteFilePath(configfile) );
file1.open(QIODevice::ReadOnly);
QTextStream stream(&file1);
checkremoteseconds=stream.readLine().toInt();
checklocalseconds=stream.readLine().toInt();
}

this was my code sir

wysota
13th February 2015, 10:50
Is it really that hard to read what I write?


What is the datatype you are using to store your "60000 seconds" value?

iswaryasenthilkumar
13th February 2015, 12:12
sorry sir.
i used datatype as QString

wysota
13th February 2015, 15:41
No, you didn't.

ChrisW67
14th February 2015, 06:19
Wysota is asking: What is the data type of the variables checkremoteseconds and checklocalseconds?

Since you don't bother to check if the configuration directory exists, the config file exists in the directory, or the file opens successfully I would add:
What is the actual value you get in those variables?
What is the value of those variables when you actually use them?

Why have you chosen to use QObject::startTimer() instead of QTimer?

iswaryasenthilkumar
16th February 2015, 05:29
i used qint16 for checkremoteseconds and checklocalseconds

Wysota is asking: What is the data type of the variables checkremoteseconds and checklocalseconds?

Since you don't bother to check if the configuration directory exists, the config file exists in the directory, or the file opens successfully I would add:
What is the actual value you get in those variables?
What is the value of those variables when you actually use them?

Why have you chosen to use QObject::startTimer() instead of QTimer?

wysota
16th February 2015, 06:45
The largest value qint16 can hold is 2^15-1 = 32767.

iswaryasenthilkumar
16th February 2015, 12:20
as yu said i did ..bt still i got same error
qint32 remoteseconds=60000
QObject::startTimer: QTimer cannot have a negative interval

The largest value qint16 can hold is 2^15-1 = 32767.

wysota
16th February 2015, 14:01
as yu said i did ..bt still i got same error
qint32 remoteseconds=60000
QObject::startTimer: QTimer cannot have a negative interval
Are you sure you are using the same variable and not locally shadowing the member/global variable you have elsewhere?

iswaryasenthilkumar
17th February 2015, 04:35
i declared qint32 checkremoteseconds in public (widget.h)
Public:
qint32 checkremoteseconds;
and assigning this 60000 by reading textfile
checkremoteseconds=stream.readLine().toInt();

Are you sure you are using the same variable and not locally shadowing the member/global variable you have elsewhere?

jefftee
17th February 2015, 06:36
You make it really hard for people to help you... :) Please post your widget.h and the file (widget.cpp?) where you read from the text file and assign your checkremoteseconds variable.

Also, what is the value of checkremoteseconds after you execute the line:



checkremoteseconds=stream.readLine().toInt();

iswaryasenthilkumar
17th February 2015, 07:14
sure .. jthomps
widget.h:

#ifndef WIDGET_H
#define WIDGET_H
#include<QtGui>
#include <QWidget>
namespace Ui {
class Widget;
}

class Widget : public QWidget
{
Q_OBJECT
public:
qint32 checklocalseconds;
qint32 checkremoteseconds;
}
widget.cpp:

#include "widget.h"
#include "ui_widget.h"
#include<QtGui>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
}
void Widget::readconfigfile()
{
dir.cd(configpath);
QFile file1;
QString configfile="DI_config.txt";//this file contains 60000,10000
file1.setFileName(dir.absoluteFilePath(configfile) );
file1.open(QIODevice::ReadOnly);
QTextStream stream(&file1);
checkremoteseconds=stream.readLine().toInt();//reading 60000
checklocalseconds=stream.readLine().toInt();//reading 10000

}
void Widget::timekeeper(checkseconds)//this check seconds contain checkremoteseconds or cj=hecklocalseconds based on seconds
{
t=new QTimer(this);
connect(t,SIGNAL(timeout()),this,SLOT(display()));
t->start(y);

}

You make it really hard for people to help you... :) Please post your widget.h and the file (widget.cpp?) where you read from the text file and assign your checkremoteseconds variable.

Also, what is the value of checkremoteseconds after you execute the line:



checkremoteseconds=stream.readLine().toInt();

jefftee
17th February 2015, 07:33
t->start(y);

Not sure exactly where to start, I seriously doubt the code you posted compiles. I fail to see how/where you are using either of the variables checkremoteseconds or checklocalseconds in the code you posted.

Where on earth did the variable "y" come from and what is its value?

When you post code, please use the
tags and copy/paste code so that you avoid typos like the ones you have in the sample code you posted please.

iswaryasenthilkumar
17th February 2015, 07:49
sorry jthomps
t->start(checkseconds)

Not sure exactly where to start, I seriously doubt the code you posted compiles. I fail to see how/where you are using either of the variables checkremoteseconds or checklocalseconds in the code you posted.

Where on earth did the variable "y" come from and what is its value?

When you post code, please use the
tags and copy/paste code so that you avoid typos like the ones you have in the sample code you posted please.

jefftee
17th February 2015, 07:57
What is the data type of checkseconds and show the code that calls method Widget::timekeeper. Rather than going back and forth with snippets of incorrect code that doesn't even show how a method is called, why don't you just post your code in its entirety?

And you continue to ignore the question regarding that values do checkremoteseconds and checklocalseconds contain after you've read the values from the text file? Set a breakpoint in the debugger and run your code and inspect the variables at run time or write out their values using qDebug() please.

wysota
17th February 2015, 08:20
Please take your actual source files, compress them into tar.gz and post your project as an attachment to your post.

Lesiok
17th February 2015, 09:15
iswaryasenthilkumar, do not be angry but I think it's time to go back to school and learn the basics of C++.

iswaryasenthilkumar
20th February 2015, 05:34
i wont get any angry..lesiok u are saying for my good one i will improve it soon
Thank you
iswaryasenthilkumar, do not be angry but I think it's time to go back to school and learn the basics of C++.