serialPort->setDataBits(QSerialPort::DataBits(ui->comboBox_databit->currentText().toUInt()));
上述基于QT的代码,实际的逻辑是,调用serialPort类里的setDataBits函数,参数则是给QSerialPort类里的DataBits函数的返回值,然后DataBits函数的参数是强制转化成无符号整型数的,ui类里的comboBox_databit里的Qstring类型的返回值。
serialPort->setDataBits(QSerialPort::DataBits(ui->comboBox_databit->currentText().toUInt()));
上述基于QT的代码,实际的逻辑是,调用serialPort类里的setDataBits函数,参数则是给QSerialPort类里的DataBits函数的返回值,然后DataBits函数的参数是强制转化成无符号整型数的,ui类里的comboBox_databit里的Qstring类型的返回值。