Results 1 to 5 of 5

Thread: Stopping QTimer

  1. #1
    Join Date
    Nov 2007
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Stopping QTimer

    Hi all,

    i am using QTimer to get Data from the parallel port at a given interval.
    this is the code:

    Qt Code:
    1. getData::getData(QWidget *parent) : QWidget(parent)
    2. {
    3. timer = new QTimer(this);
    4. }
    5.  
    6. void getData::set()
    7. {
    8. fft.Data();
    9. parport.setPortBi();
    10. clk = 0;
    11. }
    12.  
    13. void getData::startTimer()
    14. {
    15. connect(timer, SIGNAL(timeout()),this, SLOT(getData()));
    16. timer->start(0.2675);
    17. }
    18.  
    19. void getData::getData()
    20. {
    21. if(clk<22050)
    22. {
    23. parport.getdata();
    24. fft.DATA[clk] = parport.finData;
    25. clk++;
    26. }
    27. else
    28. {
    29. timer->stop();
    30. return;
    31. }
    32. }
    To copy to clipboard, switch view to plain text mode 

    now i want that after 22050 times it stops the timer and return. But it is not stopping and is continuing to enter the function that is connected with.

    Do anyone now what i am doing wrong, or a different code that do the same function??

    10x
    Adrian

  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: Stopping QTimer

    QTimer::start() takes an integer, not a real number, thus you are effectively passing it a "0". That's probably your problem. If you want it to tick every 0.2675s then pass 267.

  3. #3
    Join Date
    Nov 2007
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Stopping QTimer

    the problem is that i need 0.2675 mseconds. is there a timer for uSeconds??

  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: Stopping QTimer

    No, forget it You'd need a real time system for that, in the first place. What is your use case?

  5. #5
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Stopping QTimer

    Hi,

    Related to Real Time OS, could Qt be used on vxWorks or QNX OS ?
    Òscar Llarch i Galán

Similar Threads

  1. Extending QTimer()
    By rishid in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2009, 01:59
  2. QThread/QObject and QTimer
    By swiety in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2008, 08:37
  3. Replies: 5
    Last Post: 6th March 2007, 05:34
  4. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  5. stopping non-singlesshot QTimer
    By quickNitin in forum Newbie
    Replies: 1
    Last Post: 15th June 2006, 10:36

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.