Results 1 to 2 of 2

Thread: QTimer with Qextserialport

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

    Default QTimer with Qextserialport

    Hi,
    Here my task is writing the data to the rs-232 port with maintaining some delay.i used qextserialport for writing the data.
    My task requires after writing the "nsheet" to the port maintain some delay and after i have to write sheet parameters,for that i used singleshot function of Qtimer,but after writing the "nsheet" my timer will not execute corresponding slot,hyperterminal will not display sheet parameters.
    can anybody solve my problem.
    thanks.
    Qt Code:
    1. QByteArray nsheet("B0");
    2. nsheet.append("0");
    3. nsheet.append(QString::number(counter,10));
    4. nsheet.append("@");
    5. port->open(QIODevice::ReadWrite);
    6. port->write(nsheet);
    7. if (ui.checkBox->isChecked())
    8. QTimer::singleShot(200,this,SLOT(SHEET1(sheet1)))
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void RadarControl::SHEET1(QByteArray &sheet1)
    2. {
    3. QByteArray sheet("");
    4. sheet.append(sheet1);
    5. sheet.remove(0,sheet1.indexOf("C",0)+1);
    6. sheet.prepend("C1");
    7. sheet.append("@");
    8. port->open(QIODevice::ReadWrite);
    9. port->write(sheet);
    10. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 6th November 2008 at 22:12. Reason: changed [wiki] to [code]

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer with Qextserialport

    You can't pass arguments in SLOT and SIGNAL macros. You have to store sheet1 somewhere else. For example you can write a custom class that will emit a signal with a parameter after a timeout.

Similar Threads

  1. Replies: 8
    Last Post: 27th March 2013, 11:51
  2. Modbus, QextSerialPort and QTimer
    By ^NyAw^ in forum General Programming
    Replies: 6
    Last Post: 27th October 2009, 16:14
  3. Extending QTimer()
    By rishid in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2009, 01:59
  4. Replies: 4
    Last Post: 30th January 2008, 10:00
  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.