Bonjour,
Je suis en train de faire un programme en C++ sur Qt afin de pouvoir récupérer des trames GPS.
Sur une ligne récupérée sur Internet afin de m'aider à progresser, j'ai une erreur qui apparaît et qui semble venir de la fonction "error".
Problème étant que je ne sais pas comment résoudre ce problème et que la recherche du mot clé "error" sur Google mène à des résultats très divers et variés et souvent sans grand intérêt pour mon cas...
Y'aurai-t-il une âme charitable pour venir à ma rescousse ?
Erreur : 'error' was not declared in this scope
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #include <QCoreApplication> #include <QDebug> #include <QIODevice> #include <QObject> #include <QSerialPort> #include <qSerialPort.h> #include <QString> #define PORT "/dev/ttyUSB0" #include <iostream> using namespace std; int main() { QString dataGPS; //const char *data; QSerialPort *port = new QSerialPort(QLatin1String(PORT)); port->open(QIODevice::ReadOnly); port->setBaudRate(QSerialPort::Baud4800); port->setDataBits(QSerialPort::Data8); port->setStopBits(QSerialPort::OneStop); port->setParity(QSerialPort::NoParity); port->setFlowControl(QSerialPort::NoFlowControl); //port->open(QIODevice::ReadOnly); cout << "Lecture en cours" << endl; if(!port->open(QIODevice::ReadOnly)){ emit error(QObject::tr("error %1").arg(port->error())); return 0; } else { dataGPS = QString::fromLatin1(port->readLine()); qDebug() << dataGPS << endl; } }
Je travaille sur Ubuntu 14.04 LTS avec QtCreator 3.0.1 basé sur Qt 5.2.1.
Merci d'avance !
Bonne journée
Partager