Results 1 to 4 of 4

Thread: QTimer dificultty

  1. #1
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTimer dificultty

    Hi,
    I have a function like below
    Qt Code:
    1. void Class Name::stop()
    2. {
    3. QByteArray p("A008@");
    4. port->open(QIODevice::ReadWrite);
    5. port->write(p);
    6. port->close();
    7. }
    To copy to clipboard, switch view to plain text mode 
    when i cal the function directly(like this stop(),The data is going to port and that will be collected at the other end.
    But the problem is when i call like below,
    Qt Code:
    1. QTimer *timer = new QTimer(this);
    2. connect(timer, SIGNAL(timeout()), this, SLOT(stop()));
    3. timer->start(1000);
    To copy to clipboard, switch view to plain text mode 
    nothing is going from the port,am not able to collect the data at other end.
    What is the problem with that above code?
    can anybody help me on this issue

    thanks a lot.

  2. #2
    Join Date
    Jul 2008
    Posts
    47
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer dificultty

    Is the timer really executed?
    Do you have an eventloop?

  3. #3
    Join Date
    Oct 2008
    Posts
    70
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Default Re: QTimer dificultty

    Please modify your code like that:

    Qt Code:
    1. void Class Name::stop()
    2. {
    3. QByteArray p("A008@");
    4. port->open(QIODevice::ReadWrite);
    5. qDebug() << "Port is opened: " << port->isOpen();
    6. qDebug() << "Written " << port->write(p); << " bytes."
    7. port->close();
    8. }
    To copy to clipboard, switch view to plain text mode 

    and show us output.

  4. #4
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTimer dificultty

    I would guess that stop() is not declared as a slot.
    I'm a rebel in the S.D.G.

Similar Threads

  1. Replies: 8
    Last Post: 27th March 2013, 11:51
  2. Extending QTimer()
    By rishid in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2009, 01:59
  3. QTimer problem
    By rajeshs in forum Qt Programming
    Replies: 3
    Last Post: 13th September 2008, 14:33
  4. QThread/QObject and QTimer
    By swiety in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2008, 08:37
  5. Replies: 5
    Last Post: 6th March 2007, 05:34

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.