Unsolved How can I see and storage the data from device in QT?
-
-
@segtteee See my previous post
-
if (ui->comboBox_databits->currentText() == "Data8")
mSerialport->setDataBits("Data8") ;
error occured .. -
@segtteee First, please read what I write more carefully, second if you get an error please post it.
This is wrong:if (ui->comboBox_databits->currentText() == "Data8") mSerialport->setDataBits("Data8") ;
As I wrote above setDataBits takes an enum not a string - why do you try to pass a string?
You should really read documentation.
Here again the code I already posted before:DataBits dataBits; if (ui->dataBits.currentText() == "Data5") dataBits = DataBits::Data5; else if .. ... // new mSerialport->setDataBits(dataBits) ;
-
@jsulm
"DataBits dataBits; " is not written . what mean "DataBits dataBits;"?
I read the docummets and see "QSerialPort::Data8"
so I write
"if (ui->comboBox_databits->currentText() == "Data8")
mSerialport(QSerialPort::Data8); "
but error occured -
@segtteee Again: what error?
-
@segtteee said in How can I see and storage the data from device in QT?:
mSerialport(QSerialPort::Data8);
I'm pretty sure thats not a valid constructor of QSerialPort and I'm even more sure that not want you want to do in this case, anyway.
-
@jsulm
if
"‘DataBits’ was not declared in this scope
DataBits dataBits; " error occuredif
"expression cannot be used as a function
mSerialport(QSerialPort::Data8); " error occured
^ -
@segtteee Change
DataBits dataBits;
to
QSerialPort::DataBits dataBits;
This does not make any sense:
mSerialport(QSerialPort::Data8);
must be
mSerialport->setDataBits(QSerialPort::Data8);
Also if you directly call mSerialport->setDataBits(QSerialPort::Data8); inside if then you do not need dataBits variable...
-
@jsulm
if (ui->comboBox_databits->currentText() == "Data8")
mSerialport->setDataBits(QSerialPort::Data8);
else if (ui->comboBox_databits->currentText() == "Data7")
mSerialport->setDataBits(QSerialPort::Data7);
else if (ui->comboBox_databits->currentText() == "Data6")
mSerialport->setDataBits(QSerialPort::Data6);
I write the above code , error not occured .
Parity,Stopbits,flowcontrol , Can I do the same with them? -
@segtteee Yes you can