Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: QObject::startTimer: QTimer cannot have a negative interval

  1. #1
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QObject::startTimer: QTimer cannot have a negative interval

    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
    Thanks for advance

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    Quote Originally Posted by iswaryasenthilkumar View Post
    after reading this file i assigned to variables
    What variables? How did you do it? Show the code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    code:
    Qt Code:
    1. #define configpath "/digital_images/config"
    2. void Widget::readconfigfile()
    3. {
    4. dir.cd(configpath);
    5. QFile file1;
    6. QString configfile="DI_config.txt";
    7. file1.setFileName(dir.absoluteFilePath(configfile));
    8. file1.open(QIODevice::ReadOnly);
    9. QTextStream stream(&file1);
    10. checkremoteseconds=stream.readLine().toInt();
    11. checklocalseconds=stream.readLine().toInt();
    12. }
    To copy to clipboard, switch view to plain text mode 
    this was my code sir
    Last edited by anda_skoa; 13th February 2015 at 12:22. Reason: missing [code] tags

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    Is it really that hard to read what I write?

    What is the datatype you are using to store your "60000 seconds" value?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    sorry sir.
    i used datatype as QString

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    No, you didn't.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    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?

  10. #10
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    i used qint16 for checkremoteseconds and checklocalseconds
    Quote Originally Posted by ChrisW67 View Post
    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?

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    The largest value qint16 can hold is 2^15-1 = 32767.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. The following user says thank you to wysota for this useful post:

    iswaryasenthilkumar (16th February 2015)

  13. #12
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    as yu said i did ..bt still i got same error
    qint32 remoteseconds=60000
    QObject::startTimer: QTimer cannot have a negative interval
    Quote Originally Posted by wysota View Post
    The largest value qint16 can hold is 2^15-1 = 32767.

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    Quote Originally Posted by iswaryasenthilkumar View Post
    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #14
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    i declared qint32 checkremoteseconds in public (widget.h)
    Public:
    qint32 checkremoteseconds;
    and assigning this 60000 by reading textfile
    checkremoteseconds=stream.readLine().toInt();
    Quote Originally Posted by wysota View Post
    Are you sure you are using the same variable and not locally shadowing the member/global variable you have elsewhere?

  16. #15
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    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:

    Qt Code:
    1. checkremoteseconds=stream.readLine().toInt();
    To copy to clipboard, switch view to plain text mode 

  17. #16
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    sure .. jthomps
    widget.h:
    Qt Code:
    1. #ifndef WIDGET_H
    2. #define WIDGET_H
    3. #include<QtGui>
    4. #include <QWidget>
    5. namespace Ui {
    6. class Widget;
    7. }
    8.  
    9. class Widget : public QWidget
    10. {
    11. Q_OBJECT
    12. public:
    13. qint32 checklocalseconds;
    14. qint32 checkremoteseconds;
    15. }
    To copy to clipboard, switch view to plain text mode 
    widget.cpp:
    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"
    3. #include<QtGui>
    4. Widget::Widget(QWidget *parent) :
    5. QWidget(parent),
    6. ui(new Ui::Widget)
    7. {
    8. }
    9. void Widget::readconfigfile()
    10. {
    11. dir.cd(configpath);
    12. QFile file1;
    13. QString configfile="DI_config.txt";//this file contains 60000,10000
    14. file1.setFileName(dir.absoluteFilePath(configfile));
    15. file1.open(QIODevice::ReadOnly);
    16. QTextStream stream(&file1);
    17. checkremoteseconds=stream.readLine().toInt();//reading 60000
    18. checklocalseconds=stream.readLine().toInt();//reading 10000
    19.  
    20. }
    21. void Widget::timekeeper(checkseconds)//this check seconds contain checkremoteseconds or cj=hecklocalseconds based on seconds
    22. {
    23. t=new QTimer(this);
    24. connect(t,SIGNAL(timeout()),this,SLOT(display()));
    25. t->start(y);
    26.  
    27. }
    To copy to clipboard, switch view to plain text mode 
    Quote Originally Posted by jthomps View Post
    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:

    Qt Code:
    1. checkremoteseconds=stream.readLine().toInt();
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 17th February 2015 at 08:14. Reason: missing [code] tags

  18. #17
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    Quote Originally Posted by iswaryasenthilkumar View Post
    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 [code][/code] tags and copy/paste code so that you avoid typos like the ones you have in the sample code you posted please.

  19. #18
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    sorry jthomps
    t->start(checkseconds)
    Quote Originally Posted by jthomps View Post
    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 [code][/code] tags and copy/paste code so that you avoid typos like the ones you have in the sample code you posted please.

  20. #19
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    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.

  21. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QObject::startTimer: QTimer cannot have a negative interval

    Please take your actual source files, compress them into tar.gz and post your project as an attachment to your post.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 6
    Last Post: 4th September 2014, 09:06
  2. Replies: 3
    Last Post: 27th August 2013, 23:25
  3. Freeze using QTimer with interval 0
    By Alundra in forum Qt Programming
    Replies: 22
    Last Post: 7th August 2013, 14:13
  4. Replies: 15
    Last Post: 4th August 2012, 19:11
  5. QTimer QBasicTimer and QObject::startTimer
    By SABROG in forum Qt Programming
    Replies: 7
    Last Post: 15th June 2009, 17:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.