QCommandLineOption Class
QCommandLineOption 클래스는 가능한 명령줄 옵션을 정의합니다. 더 보기...
Header: | #include <QCommandLineOption> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
- 상속된 멤버를 포함한 모든 멤버 목록
- QCommandLineOption은 암시적으로 공유되는 클래스의 일부입니다.
공용 유형
공용 함수
QCommandLineOption(const QString &name) | |
QCommandLineOption(const QStringList &names) | |
QCommandLineOption(const QString &name, const QString &description, const QString &valueName = QString(), const QString &defaultValue = QString()) | |
QCommandLineOption(const QStringList &names, const QString &description, const QString &valueName = QString(), const QString &defaultValue = QString()) | |
QCommandLineOption(const QCommandLineOption &other) | |
~QCommandLineOption() | |
QStringList | defaultValues() const |
QString | description() const |
QCommandLineOption::Flags | flags() const |
QStringList | names() const |
void | setDefaultValue(const QString &defaultValue) |
void | setDefaultValues(const QStringList &defaultValues) |
void | setDescription(const QString &description) |
void | setFlags(QCommandLineOption::Flags flags) |
void | setValueName(const QString &valueName) |
void | swap(QCommandLineOption &other) |
QString | valueName() const |
QCommandLineOption & | operator=(QCommandLineOption &&other) |
QCommandLineOption & | operator=(const QCommandLineOption &other) |
상세 설명
이 클래스는 명령줄에 옵션을 설명하는 데 사용됩니다. 여러 별칭을 사용하여 동일한 옵션을 여러 가지 방식으로 정의할 수 있습니다. 또한 옵션이 어떻게 사용되는지 설명하는 데 사용되며, 플래그(예: -v
)이거나 값(예: -o file
)을 취할 수 있습니다.
예시:
QCommandLineOption verboseOption("verbose", "Verbose mode. Prints out more information."); QCommandLineOption outputOption(QStringList() << "o" << "output", "Write generated data into <file>.", "file");
QCommandLineParser 를참조하세요 .
멤버 유형 문서
열거형 QCommandLineOption::플래그
플래그 QCommandLineOption::플래그
Constant | 값 | 설명 |
---|---|---|
QCommandLineOption::HiddenFromHelp | 0x1 | 사용자가 볼 수 있는 도움말 출력에서 이 옵션을 숨깁니다. 기본적으로 모든 옵션이 표시됩니다. 특정 옵션에 대해 이 플래그를 설정하면 해당 옵션이 내부적으로, 즉 도움말 출력에 나열되지 않습니다. |
QCommandLineOption::ShortOptionStyle | 0x2 | 이 옵션은 QCommandLineParser::setSingleDashWordOptionMode 에 설정된 것과 관계없이 항상 짧은 옵션으로 이해됩니다. 따라서 구문 분석기가 QCommandLineParser::ParseAsLongOptions 모드일 때도 -DDEFINE=VALUE 또는 -I/include/path 같은 플래그가 짧은 플래그로 해석될 수 있습니다. |
Flags 유형은 QFlags<Flag>에 대한 typedef입니다. 플래그 값의 OR 조합을 저장합니다.
QCommandLineOption::setFlags() 및 QCommandLineOption::flags()도 참조하세요 .
멤버 함수 문서
[explicit]
QCommandLineOption::QCommandLineOption(const QString &name)
name 라는 이름의 명령줄 옵션 개체를 생성합니다.
이름은 짧거나 길 수 있습니다. 이름이 한 글자 길이인 경우 짧은 이름으로 간주됩니다. 옵션 이름은 비어 있으면 안 되고, 대시나 슬래시 문자로 시작해서는 안 되며, =
을 포함해서는 안 되고, 반복해서 사용할 수 없습니다.
setDescription(), setValueName() 및 setDefaultValues()도 참조하세요 .
[explicit]
QCommandLineOption::QCommandLineOption(const QStringList &names)
names 라는 이름의 명령줄 옵션 객체를 생성합니다.
이 오버로드를 사용하면 옵션의 이름을 여러 개 설정할 수 있습니다(예: o
및 output
).
이름은 짧거나 길 수 있습니다. 목록에서 한 글자 길이인 이름은 모두 짧은 이름입니다. 옵션 이름은 비어 있으면 안 되고, 대시나 슬래시 문자로 시작해서는 안 되며, =
을 포함해서는 안 되고, 반복해서 사용할 수 없습니다.
setDescription(), setValueName() 및 setDefaultValues()도 참조하세요 .
QCommandLineOption::QCommandLineOption(const QString &name, const QString &description, const QString &valueName = QString(), const QString &defaultValue = QString())
주어진 인수를 사용하여 명령줄 옵션 객체를 만듭니다.
옵션의 이름은 name 로 설정됩니다. 이름은 짧거나 길 수 있습니다. 이름이 한 글자 길이인 경우 짧은 이름으로 간주합니다. 옵션 이름은 비어 있으면 안 되고, 대시나 슬래시 문자로 시작해서는 안 되며, =
을 포함해서는 안 되고, 반복해서 사용할 수 없습니다.
설명은 description 으로 설정되며 설명 끝에 "."를 추가하는 것이 일반적입니다.
또한 옵션에 값이 필요한 경우 valueName 을 설정해야 합니다. 옵션의 기본값은 defaultValue 로 설정되어 있습니다.
5.4 이전 Qt 버전에서는 이 생성자가 explicit
였습니다. Qt 5.4 이상에서는 더 이상 이 생성자가 아니며 균일 초기화에 사용할 수 있습니다:
QCommandLineParser parser; parser.addOption({"verbose", "Verbose mode. Prints out more information."});
setDescription(), setValueName() 및 setDefaultValues()도 참조하십시오 .
QCommandLineOption::QCommandLineOption(const QStringList &names, const QString &description, const QString &valueName = QString(), const QString &defaultValue = QString())
주어진 인수를 사용하여 명령줄 옵션 객체를 생성합니다.
이 오버로드를 사용하면 옵션의 이름을 여러 개 설정할 수 있습니다(예: o
및 output
).
옵션의 이름은 names 로 설정됩니다. 이름은 짧거나 길 수 있습니다. 목록에서 한 글자 길이인 이름은 모두 짧은 이름입니다. 옵션 이름은 비어 있으면 안 되고, 대시나 슬래시 문자로 시작하면 안 되며, =
을 포함해서는 안 되고, 반복해서 사용할 수 없습니다.
설명은 description 으로 설정되며 설명 끝에 "."를 추가하는 것이 일반적입니다.
또한 옵션에 값이 필요한 경우 valueName 을 설정해야 합니다. 옵션의 기본값은 defaultValue 로 설정되어 있습니다.
5.4 이전 Qt 버전에서는 이 생성자가 explicit
였습니다. Qt 5.4 이상에서는 더 이상 이 생성자가 아니며 균일 초기화에 사용할 수 있습니다:
QCommandLineParser parser; parser.addOption({{"o", "output"}, "Write generated data into <file>.", "file"});
setDescription(), setValueName() 및 setDefaultValues()도 참조하십시오 .
QCommandLineOption::QCommandLineOption(const QCommandLineOption &other)
QCommandLineOption 객체의 복사본인 QCommandLineOption 객체를 구축합니다 other.
operator=()도 참조하세요 .
[noexcept]
QCommandLineOption::~QCommandLineOption()
명령줄 옵션 개체를 삭제합니다.
QStringList QCommandLineOption::defaultValues() const
이 옵션에 설정된 기본값을 반환합니다.
setDefaultValues()도 참조하세요 .
QString QCommandLineOption::description() const
이 옵션에 설정된 설명을 반환합니다.
setDescription()도 참조하세요 .
QCommandLineOption::Flags QCommandLineOption::flags() const
이 명령줄 옵션에 영향을 주는 플래그 집합을 반환합니다.
setFlags() 및 QCommandLineOption::Flags도 참조하세요 .
QStringList QCommandLineOption::names() const
이 옵션에 설정된 이름을 반환합니다.
void QCommandLineOption::setDefaultValue(const QString &defaultValue)
이 옵션에 사용되는 기본값을 defaultValue 로 설정합니다.
애플리케이션 사용자가 명령줄에서 옵션을 지정하지 않으면 기본값이 사용됩니다.
defaultValue 이 비어 있으면 옵션에 기본값이 없습니다.
defaultValues() 및 setDefaultValues()도 참조하세요 .
void QCommandLineOption::setDefaultValues(const QStringList &defaultValues)
이 옵션에 사용되는 기본값 목록을 defaultValues 로 설정합니다.
애플리케이션 사용자가 명령줄에서 옵션을 지정하지 않으면 기본값이 사용됩니다.
defaultValues() 및 setDefaultValue()도 참조하세요 .
void QCommandLineOption::setDescription(const QString &description)
이 옵션에 사용되는 설명을 description 로 설정합니다.
설명 끝에 "."를 추가하는 것이 일반적입니다.
설명은 QCommandLineParser::showHelp()에서 사용됩니다.
description()도 참조하세요 .
void QCommandLineOption::setFlags(QCommandLineOption::Flags flags)
이 명령줄 옵션에 영향을 주는 플래그 집합을 flags 으로 설정합니다.
flags() 및 QCommandLineOption::Flags도 참조하세요 .
void QCommandLineOption::setValueName(const QString &valueName)
문서에 대한 예상 값의 이름을 valueName 로 설정합니다.
값이 할당되지 않은 옵션은 사용자가 -option을 지정하거나 지정하지 않는 경우 부울과 같은 동작을 합니다.
값이 할당된 옵션은 도움말 출력의 옵션 문서에 예상되는 값의 이름을 설정해야 합니다. 이름이 o
및 output
인 옵션과 값 이름이 file
인 옵션은 -o, --output <file>
으로 표시됩니다.
옵션이 한 번만 표시될 것으로 예상되는 경우에는 QCommandLineParser::value()를 호출하고, 여러 번 표시될 것으로 예상되는 경우에는 QCommandLineParser::values()를 호출하세요.
valueName()도 참조하세요 .
[noexcept]
void QCommandLineOption::swap(QCommandLineOption &other)
이 옵션을 other 로 바꿉니다. 이 작업은 매우 빠르며 실패하지 않습니다.
QString QCommandLineOption::valueName() const
예상 값의 이름을 반환합니다.
비어 있으면 이 옵션은 값을 받지 않습니다.
setValueName()도 참조하세요 .
[noexcept]
QCommandLineOption &QCommandLineOption::operator=(QCommandLineOption &&other)
이동-이 other 인스턴스를 QCommandLineOption 인스턴스에 할당합니다.
QCommandLineOption &QCommandLineOption::operator=(const QCommandLineOption &other)
other 객체의 복사본을 만들어 이 QCommandLineOption 객체에 할당합니다.
© 2025 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.