内容表

上一话题

QCollatorSortKey

下一话题

QCommandLineParser

QCommandLineOption

QCommandLineOption class defines a possible command-line option. 更多

Inheritance diagram of PySide2.QtCore.QCommandLineOption

New in version 5.2.

概要

函数

详细描述

This class is used to describe an option on the command line. It allows different ways of defining the same option with multiple aliases possible. It is also used to describe how the option is used - it may be a flag (e.g. -v ) or take a value (e.g. -o file ).

范例:

QCommandLineOption verboseOption("verbose", "Verbose mode. Prints out more information.");
QCommandLineOption outputOption(QStringList() << "o" << "output", "Write generated data into <file>.", "file");
											
class QCommandLineOption ( other )

QCommandLineOption(name)

QCommandLineOption(name, description[, valueName=””[, defaultValue=””]])

QCommandLineOption(names)

QCommandLineOption(names, description[, valueName=””[, defaultValue=””]])

参数
  • name – unicode

  • valueName – unicode

  • other QCommandLineOption

  • description – unicode

  • names – 字符串列表

  • defaultValue – unicode

PySide2.QtCore.QCommandLineOption. Flag

常量

描述

QCommandLineOption.HiddenFromHelp

Hide this option in the user-visible help output. All options are visible by default. Setting this flag for a particular option makes it internal, i.e. not listed in the help output.

QCommandLineOption.ShortOptionStyle

The option will always be understood as a short option, regardless of what was set by setSingleDashWordOptionMode . This allows flags such as -DDEFINE=VALUE or -I/include/path to be interpreted as short flags even when the parser is in ParseAsLongOptions 模式。

New in version 5.8.

PySide2.QtCore.QCommandLineOption. defaultValues ( )
返回类型

字符串列表

返回此选项的默认值设置。

PySide2.QtCore.QCommandLineOption. description ( )
返回类型

unicode

返回此选项的描述设置。

另请参阅

setDescription()

PySide2.QtCore.QCommandLineOption. flags ( )
返回类型

标志

Returns a set of flags that affect this command-line option.

另请参阅

setFlags() 标志

PySide2.QtCore.QCommandLineOption. isHidden ( )
返回类型

bool

注意

此函数被弃用。

Returns true if this option is omitted from the help output, false if the option is listed.

使用 flags() & HiddenFromHelp

另请参阅

setHidden() HiddenFromHelp

PySide2.QtCore.QCommandLineOption. names ( )
返回类型

字符串列表

Returns the names set for this option.

PySide2.QtCore.QCommandLineOption. setDefaultValue ( defaultValue )
参数

defaultValue – unicode

Sets the default value used for this option to defaultValue .

The default value is used if the user of the application does not specify the option on the command line.

defaultValue is empty, the option has no default values.

PySide2.QtCore.QCommandLineOption. setDefaultValues ( defaultValues )
参数

defaultValues – 字符串列表

Sets the list of default values used for this option to defaultValues .

The default values are used if the user of the application does not specify the option on the command line.

PySide2.QtCore.QCommandLineOption. setDescription ( description )
参数

description – unicode

Sets the description used for this option to description .

It is customary to add a “.” at the end of the description.

The description is used by showHelp() .

另请参阅

description()

PySide2.QtCore.QCommandLineOption. setFlags ( aflags )
参数

aflags 标志

Set the set of flags that affect this command-line option to flags .

另请参阅

flags() 标志

PySide2.QtCore.QCommandLineOption. setHidden ( hidden )
参数

hidden bool

注意

此函数被弃用。

Sets whether to hide this option in the user-visible help output.

All options are visible by default. Setting hide to true for a particular option makes it internal, i.e. not listed in the help output.

使用 setFlags ( HiddenFromHelp ), HiddenFromHelp

另请参阅

isHidden

PySide2.QtCore.QCommandLineOption. setValueName ( name )
参数

name – unicode

Sets the name of the expected value, for the documentation, to valueName .

Options without a value assigned have a boolean-like behavior: either the user specifies –option or they don’t.

Options with a value assigned need to set a name for the expected value, for the documentation of the option in the help output. An option with names o and output , and a value name of file will appear as -o, --output <file> .

调用 value() if you expect the option to be present only once, and values() if you expect that option to be present multiple times.

另请参阅

valueName()

PySide2.QtCore.QCommandLineOption. swap ( other )
参数

other QCommandLineOption

Swaps option other with this option. This operation is very fast and never fails.

PySide2.QtCore.QCommandLineOption. valueName ( )
返回类型

unicode

返回期望值的名称。

If empty, the option doesn’t take a value.

另请参阅

setValueName()