Question: I have problem with my Arduino app in Qt 5.1.1

I have used QextSerialPort and then I wanted to upgrade to QtSerialPort which is a part of Qt5.1.1

The app was working with QextSerialPort.
So I have only changed some things but in core it should be the same. Therefore I am wondering why I can't connect to Arduino. 

When asking for errorString() the answer is 'handle is invalid'

This is my code:

```
void MainWindow::init_schnittstelle()
{
    port = new QSerialPort; //create the port

    port->setPortName(schnittstelle); //create the port
    port->setBaudRate(QSerialPort::Baud115200);
    port->setFlowControl(QSerialPort::NoFlowControl);
    port->setParity(QSerialPort::NoParity);
    port->setDataBits(QSerialPort::Data8);
    port->setStopBits(QSerialPort::OneStop);

    port->open(QIODevice::ReadWrite | QIODevice::Unbuffered); //open the port
    schnittstelleZustand = port->errorString();

    if(!port->isOpen())
    {
        QMessageBox::warning(this, "Schnittstelle", "Schnittstelle "+schnittstelle+" reagiert nicht. "+schnittstelleZustand);
    }
    else{
        schnittstelleZustand = ("verbunden");
    }

}

```

In the variable schnittstelle is given the address. I can connect to arduino per Arduino software so I am sure that my Arduino is on COM10 but this says me it is not...

What's wrong?

Answer: 
I checked Qt documentation and I saw:

> 
> Warning: The mode has to be QIODevice::ReadOnly, QIODevice::WriteOnly, or QIODevice::ReadWrite. Other modes are unsupported.
> 
> 
> 

Change your code

```
port->open(QIODevice::ReadWrite | QIODevice::Unbuffered);

```

to

```
port->open(QIODevice::ReadWrite);

```

and try again.

There is documentation link

<http://qt-project.org/doc/qt-5/qserialport.html#open>
<http://qt-project.org/doc/qt-5.1/qtserialport/qserialport.html#details>

> 
> Provides functions to access serial ports. 
> 
> 
> You can get information
>  about the available serial ports using the `QSerialPortInfo` helper
>  class, which allows an enumeration of all the serial ports in the
>  system. This is useful to obtain the correct name of the serial port
>  you want to use. You can pass an object of the helper class as an
>  argument to the `setPort()` or `setPortName()` methods to assign the
>  desired serial device.
> 
> 
> 

Try enumerating your ports using a `QSerialPortInfo` object, and then print out the port names.

<http://qt-project.org/doc/qt-5.1/qtserialport/qserialportinfo.html#portName>

After you have a valid port name, your invalid handle should go away.

Hope that helps.