Unsolved Find the current port and open it
-
@suslucoder I mean: is a port selected in combo box (or what ever widget ui->ports is)?
-
@jsulm yes it was selected
-
@suslucoder How do you know that ui->ports->currentText() returns an empty string?
-
@jsulm from here
if (serial->open(QIODevice::ReadWrite)) { qDebug() << currentPortName << "is Open "; serial->clear(); write_Json(); connect(serial, &QSerialPort::readyRead, this, &MainWindow::on_Serial_Read); }
-
@suslucoder You don't use ui->ports->currentText() anywhere in your code you show us here ...
-
@suslucoder said in Find the current port and open it:
currentPortName
If you mean this one, then this is wrong as you only set it once when nothing is selected! Use ui->ports->currentText():
qDebug() << ui->ports->currentText() << "is Open ";
-
@Christian-Ehrlicher im using it to open the port?
serial->setPortName(ui->ports->currentText());
-
@jsulm it returns empty again
-
@suslucoder said in Find the current port and open it:
it returns empty again
How did you verify that?
Please addqDebug() << ui->ports->currentText();
and see what it prints out.
-
@jsulm said in Find the current port and open it:
qDebug() << ui->ports->currentText();
I've add it. It returns empty string.
Like ""
Why you didnt believe me? -
@suslucoder said in Find the current port and open it:
Why you didnt believe me?
Because it was not clear how you actually verified that it is indeed empty. Often people simply assume something, that's why it's worth asking.
-
Please output also the count and the current index of the combobox. Is it really filled? Do you create it two times by accident?