- Qt 5.15
- Qt Serial Port
- C++ Classes
- QSerialPort
- Qt 5.15.19 Reference Documentation

# Obsolete Members for QSerialPort

The following members of class QSerialPort are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

## Public Types

`(obsolete)` enum | DataErrorPolicy { SkipPolicy, PassZeroPolicy, IgnorePolicy, StopReceivingPolicy, UnknownPolicy }

## Properties

- `(obsolete)` dataErrorPolicy : DataErrorPolicy
- `(obsolete)` settingsRestoredOnClose : bool

## Public Functions

`(obsolete)` DataErrorPolicy | dataErrorPolicy() const
`(obsolete)` bool | setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy)
`(obsolete)` void | setSettingsRestoredOnClose(bool restore)
`(obsolete)` bool | settingsRestoredOnClose() const

## Signals

`(obsolete)` void | dataErrorPolicyChanged(QSerialPort::DataErrorPolicy policy)
`(obsolete)` void | error(QSerialPort::SerialPortError error)
`(obsolete)` void | settingsRestoredOnCloseChanged(bool restore)

## Member Type Documentation

### enum QSerialPort::DataErrorPolicy

This enum is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

This enum describes the policies for the received symbols while parity errors were detected.

Constant | Value | Description
--- | --- | ---
`QSerialPort::SkipPolicy` | `0` | Skips the bad character.
`QSerialPort::PassZeroPolicy` | `1` | Replaces bad character with zero.
`QSerialPort::IgnorePolicy` | `2` | Ignores the error for a bad character.
`QSerialPort::StopReceivingPolicy` | `3` | Stops data reception on error.
`QSerialPort::UnknownPolicy` | `-1` | Unknown policy.

See also QSerialPort::dataErrorPolicy.

## Property Documentation

### dataErrorPolicy : DataErrorPolicy

This property is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

This property holds the error policy for how the process receives characters in the case where a parity error is detected.

If the setting is successful, returns `true`; otherwise returns `false`. The default policy set is IgnorePolicy.

Note: The serial port has to be open before trying to set this property; otherwise returns `false` and sets the NotOpenError error code. This is a bit unusual as opposed to the regular Qt property settings of a class. However, this is a special use case since the property is set through the interaction with the kernel and hardware. Hence, the two scenarios cannot be completely compared to each other.

Access functions:

DataErrorPolicy | dataErrorPolicy() const
bool | setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy)

Notifier signal:

void | dataErrorPolicyChanged(QSerialPort::DataErrorPolicy policy)

### settingsRestoredOnClose : bool

This property is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

This property holds the flag which specifies to restore the previous settings when closing the serial port.

If this flag is `true`, the settings will be restored; otherwise not. The default state of the QSerialPort class is to restore the settings.

Access functions:

bool | settingsRestoredOnClose() const
void | setSettingsRestoredOnClose(bool restore)

Notifier signal:

void | settingsRestoredOnCloseChanged(bool restore)

## Member Function Documentation

### `[signal]` void QSerialPort::dataErrorPolicyChanged(QSerialPort::DataErrorPolicy policy)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

This signal is emitted after the error policy for how the process receives characters in case of parity error detection has been changed. The new error policy for how the process receives the character in case of parity error detection is passed as policy.

Note: Notifier signal for property dataErrorPolicy.

See also QSerialPort::dataErrorPolicy.

### `[signal]` void QSerialPort::error(QSerialPort::SerialPortError error)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use errorOccurred() instead.

Note: Signal error is overloaded in this class. To connect to this signal by using the function pointer syntax, Qt provides a convenient helper for obtaining the function pointer as shown in this example:

     connect(serialPort, QOverload<QSerialPort::SerialPortError>::of(&QSerialPort::error),
         [=](QSerialPort::SerialPortError error){ /* ... */ });

### `[signal]` void QSerialPort::settingsRestoredOnCloseChanged(bool restore)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

This signal is emitted after the flag which specifies to restore the previous settings while closing the serial port has been changed. The new flag which specifies to restore the previous settings while closing the serial port is passed as restore.

Note: Notifier signal for property settingsRestoredOnClose.

See also QSerialPort::settingsRestoredOnClose.