이 페이지에서

QSerialPortInfo Class

기존 직렬 포트에 대한 정보를 제공합니다. 더 보기...

헤더: #include <QSerialPortInfo>
CMake: find_package(Qt6 REQUIRED COMPONENTS SerialPort)
target_link_libraries(mytarget PRIVATE Qt6::SerialPort)
qmake: QT += serialport

공개 함수

QSerialPortInfo()
QSerialPortInfo(const QSerialPort &port)
QSerialPortInfo(const QString &name)
QSerialPortInfo(const QSerialPortInfo &other)
~QSerialPortInfo()
QString description() const
bool hasProductIdentifier() const
bool hasVendorIdentifier() const
bool isNull() const
QString manufacturer() const
QString portName() const
quint16 productIdentifier() const
QString serialNumber() const
void swap(QSerialPortInfo &other)
QString systemLocation() const
quint16 vendorIdentifier() const
QSerialPortInfo &operator=(const QSerialPortInfo &other)

정적 공용 멤버

QList<QSerialPortInfo> availablePorts()
QList<qint32> standardBaudRates()

상세 설명

정적 함수 ` availablePorts()`을 사용하여 `QSerialPortInfo` 객체 목록을 생성합니다. 목록에 포함된 각 `QSerialPortInfo` 객체는 하나의 시리얼 포트를 나타내며, ` port name`, ` system location`, ` description`, ` manufacturer` 및 기타 몇 가지 하드웨어 매개변수를 조회할 수 있습니다. 또한 `QSerialPortInfo` 클래스는 ` QSerialPort ` 클래스의 ` setPort()` 메서드의 입력 매개변수로도 사용할 수 있습니다.

사용 예시

다음 예제 코드는 사용 가능한 모든 시리얼 포트를 열거하고 해당 매개변수를 콘솔에 출력합니다:

   const auto serialPortInfos = QSerialPortInfo::availablePorts();
    for (const QSerialPortInfo&portInfo: serialPortInfos) {
        qDebug() << "\n"
                << "포트:" << portInfo.portName() << "\n"
                 << "위치:" << portInfo.systemLocation() << "\ n "
                 << "설명:" << portInfo.description() << "\n"
                << "제조사:" << portInfo.manufacturer() << "\n"
                 << "일련번호:" << portInfo.serialNumber() << "\n"
                 << "벤더 식별자:"
                << (portInfo.hasVendorIdentifier()
                     ? QByteArray::number(portInfo.vendorIdentifier(), 16)
                     : QByteArray()) << "\n"
                 << "제품 식별자:"
                 << (portInfo.hasProductIdentifier()
                     ? QByteArray::number(portInfo.productIdentifier(), 16)
                     : QByteArray());
    }

Linux에서의 포트 열거

기본적으로 리눅스는 libudev 를 사용하여 사용 가능한 직렬 포트를 열거합니다. 해당 라이브러리를 사용할 수 없는 경우, /sys/class/tty 디렉터리에 있는 파일을 읽는 방식으로 대체됩니다.

일부 버전의 libudev 에는 버그가 있어 실제 장치 대신 USB 허브의 VID 및 PID를 잘못 보고하는 것으로 알려져 있습니다. 이러한 경우, QT_SERIALPORT_SKIP_UDEV_LOOKUP 환경 변수를 정의하여 libudev 검색을 건너뛰고 /sys/class/tty 디렉터리의 정보만 사용하도록 하십시오.

QSerialPort도 참조하십시오 .

멤버 함수 문서

QSerialPortInfo::QSerialPortInfo()

빈 QSerialPortInfo 객체를 생성합니다.

isNull()도 참조하십시오 .

[explicit] QSerialPortInfo::QSerialPortInfo(const QSerialPort &port)

시리얼 port 를 기반으로 QSerialPortInfo 객체를 생성합니다.

[explicit] QSerialPortInfo::QSerialPortInfo(const QString &name)

name 시리얼 포트를 기반으로 QSerialPortInfo 객체를 생성합니다.

이 생성자는 포트 이름 name 에 따라 사용 가능한 시리얼 포트 중에서 해당 포트를 찾아내고, 해당 포트에 대한 시리얼 포트 정보 인스턴스를 생성합니다.

QSerialPortInfo::QSerialPortInfo(const QSerialPortInfo &other)

other 의 복사본을 생성합니다.

[noexcept] QSerialPortInfo::~QSerialPortInfo()

QSerialPortInfo 객체를 삭제합니다. 이 객체의 값에 대한 참조는 더 이상 유효하지 않게 됩니다.

[static] QList<QSerialPortInfo> QSerialPortInfo::availablePorts()

시스템에서 사용 가능한 직렬 포트 목록을 반환합니다.

Port enumeration on Linux도 참조하십시오 .

QString QSerialPortInfo::description() const

사용 가능한 경우 시리얼 포트의 설명 문자열을 반환하고, 그렇지 않으면 빈 문자열을 반환합니다.

manufacturer() 및 serialNumber()도 참조하십시오 .

bool QSerialPortInfo::hasProductIdentifier() const

유효한 16-bit 제품 번호가 존재하면 true 를 반환하고, 그렇지 않으면 false 를 반환합니다.

productIdentifier(), vendorIdentifier(), hasVendorIdentifier()도 참조하십시오 .

bool QSerialPortInfo::hasVendorIdentifier() const

유효한 16-bit 공급업체 번호가 존재하면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

vendorIdentifier(), productIdentifier(), hasProductIdentifier()도 참조하십시오 .

bool QSerialPortInfo::isNull() const

이 QSerialPortInfo 객체가 시리얼 포트 정의를 포함하고 있는지 여부를 반환합니다.

QString QSerialPortInfo::manufacturer() const

사용 가능한 경우 시리얼 포트의 제조사 문자열을 반환하고, 그렇지 않으면 빈 문자열을 반환합니다.

description() 및 serialNumber()도 참조하십시오 .

QString QSerialPortInfo::portName() const

직렬 포트의 이름을 반환합니다.

systemLocation()도 참조하십시오 .

quint16 QSerialPortInfo::productIdentifier() const

사용 가능한 경우 직렬 포트에 대한 16비트 제품 번호를 반환하고, 그렇지 않은 경우 0을 반환합니다.

hasProductIdentifier(), vendorIdentifier() 및 hasVendorIdentifier()도 참조하십시오 .

QString QSerialPortInfo::serialNumber() const

사용 가능한 경우 직렬 포트의 일련 번호 문자열을 반환하고, 그렇지 않으면 빈 문자열을 반환합니다.

참고: 일련번호에는 문자가 포함될 수 있습니다.

description() 및 manufacturer()도 참조하십시오 .

[static] QList<qint32> QSerialPortInfo::standardBaudRates()

대상 플랫폼에서 지원하는 사용 가능한 표준 보드 레이트 목록을 반환합니다.

void QSerialPortInfo::swap(QSerialPortInfo &other)

QSerialPortInfo other 를 QSerialPortInfo 로 교체합니다. 이 작업은 매우 빠르며 절대 실패하지 않습니다.

QString QSerialPortInfo::systemLocation() const

직렬 포트의 시스템 위치를 반환합니다.

portName()도 참조하십시오 .

quint16 QSerialPortInfo::vendorIdentifier() const

사용 가능한 경우 시리얼 포트에 대한 16비트 벤더 번호를 반환하고, 그렇지 않으면 0을 반환합니다.

hasVendorIdentifier(), productIdentifier(), hasProductIdentifier()도 참조하십시오 .

QSerialPortInfo &QSerialPortInfo::operator=(const QSerialPortInfo &other)

QSerialPortInfo 객체를 other 과 동일하게 설정합니다.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.