title: QT c++ open Serial port more than once
body: <p>I search an example to open multiple serial ports in qt. </p>
  
  <p>My open port function settings forward from other class</p>
  
  <pre><code>void MainWindow::openSerialPort(){
      SettingsDialog::Settings p = settings-&gt;settings();
      serial-&gt;setPortName(p.name);
      serial-&gt;setBaudRate(QSerialPort::Baud9600);
      serial-&gt;setDataBits(QSerialPort::Data8);
      serial-&gt;setParity(QSerialPort::NoParity);
      serial-&gt;setStopBits(QSerialPort::OneStop);
      serial-&gt;setFlowControl(QSerialPort::NoFlowControl);
  
  if (serial-&gt;open(QIODevice::ReadWrite)) { 
      ui-&gt;connectAction-&gt;setEnabled(false);
      ui-&gt;disconnectAction-&gt;setEnabled(true);
      ui-&gt;settingsAction-&gt;setEnabled(false);
      showStatusMessage(tr("Connected to %1 : OK")
                        .arg(p.name));
  } else { //gdy sie nie udalo error
      QMessageBox::critical(this, tr("Error"), serial-&gt;errorString());
  
      showStatusMessage(tr("Open error"));
  }
  }
  </code></pre>