Results 1 to 20 of 22

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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.


  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

    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?

  4. #4
    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 

  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

    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

  6. #6
    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.

  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 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.

  8. #8
    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.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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.


  10. #10
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    iswaryasenthilkumar, do not be angry but I think it's time to go back to school and learn the basics of C++.

  11. #11
    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 wont get any angry..lesiok u are saying for my good one i will improve it soon
    Thank you
    Quote Originally Posted by Lesiok View Post
    iswaryasenthilkumar, do not be angry but I think it's time to go back to school and learn the basics of C++.

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
  •  
Qt is a trademark of The Qt Company.