Regarding Projector Programming using QT
-
@Prath You know how to connect a slot to a signal?
https://doc.qt.io/qt-5/signalsandslots.html -
Yeah @jsulm . We have to connect this signal [signal]void QSerialPort::errorOccurred(QSerialPort::SerialPortError error) to the slot right?
Is this correct?
void MainWindow::errorReport(QSerialPort::SerialPortError error)
{
if(error!=0)
qDebug()<<"ERROR:"<<endl<<error; // nothing printed
}connect(this->Serial,SIGNAL(error(QSerialPort::SerialPortError)),this,SLOT(errorReport(QSerialPort::SerialPortError)));
-
@Prath said in Regarding Projector Programming using QT:
Is this correct?
Signal is https://doc.qt.io/qt-5/qserialport.html#errorOccurred not error. Just check the documentation.
-
@Prath
You wroteconnect(this->Serial,SIGNAL(error(QSerialPort::SerialPortError)),this,SLOT(errorReport(QSerialPort::SerialPortError)));
Where you have
SIGNAL(error(QSerialPort::SerialPortError))
@jsulm is expectingSIGNAL(errorOccurred(QSerialPort::SerialPortError))
. If what you have works, we do not understand how.If you are writing new code and would change over to the new signal/slot syntax you would presumably receive a compile-time error.
-
Your MainWindow class does not have such a signal, it's one from the QSerialPort.
-
@Prath said in Regarding Projector Programming using QT:
What's your take?
Your connect is wrong: MainWindow does NOT have signal error(QSerialPort::QSerialPort), this signal is in QSerialPort, so not in "this" but in "serial".
And please do not post screen-shots, copy paste your code...
-
this signal is in QSerialPort, so not in "this" but in "serial".
Is this a case where changing to new-style signal/slot syntax would generate an error for the wrong "context" variable? Or, would testing the return result from the
connect()
or from https://doc.qt.io/qt-5/qmetaobject-connection.html#operator-bool in code tell the user if the connection has failed because of the wrong context? -
If you mean use several QSerialPorts at the same time in one application then yes, no problem with that. If you mean something else, please give more details.