class MyClass : public QObject{public: explicit MyClass() { port = new QSerialPort(this); port->setPortName("COM1"); connect(port, SIGNAL(dataTerminalReadyChanged(bool)), this, SLOT(onDtr(bool))); timer = new QTimer(this); timer->setSingleShot(); connect(timer, SIGNAL(timeout()), this, SLOT(onTimer())); } void startPulse() { if (!port->open(QIODevice::ReadWrite)) return; port->setDataTerminalReady(true); } private slots: void onTimer() { port->setDataTerminalReady(false); } void onDtr(bool set) { if (set) { timer->start(50); // ~50msec :) } else { port->close(); } } private: QSerialPort *port; QTimer *timer;}