最后一种对话框是QInputDialog,,用来提供个输入的窗口。

一常用的静态方法

  由于输入的类型不同,QInputDialog分为多种静态方法使用

#有步长调节器的整形数据,step为步长调节器的增量设定
QInputDialog.getInt(parent: QWidget, title: str, label: str, value: int = ..., min: int = ..., max: int = ..., step: int = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...)
#有步长调节器的浮点形数据,decimals为小数位数
QInputDialog.getDouble(parent: QWidget, title: str, label: str, value: float = ..., min: float = ..., max: float = ..., decimals: int = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...)
#单行文本数据,echo为输出模式(明文、密码或不显示)
QInputDialog.getText(parent: QWidget, title: str, label: str, echo: 'QLineEdit.EchoMode' = ..., text: str = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ..., inputMethodHints: typing.Union[QtCore.Qt.InputMethodHints, QtCore.Qt.InputMethodHint] = ...)
#多行文本
QInputDialog.getMultiLineText(parent: QWidget, title: str, label: str, text: str = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ..., inputMethodHints: typing.Union[QtCore.Qt.InputMethodHints, QtCore.Qt.InputMethodHint] = ...)
# #下拉列表,qizhong item为下拉列表的内容,迭代内从必须是字符串格式
QInputDialog.getItem(parent: QWidget, title: str, label: str, items: typing.Iterable[str], current: int = ..., editable: bool = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ..., inputMethodHints: typing.Union[QtCore.Qt.InputMethodHints, QtCore.Qt.InputMethodHint] = ...)

所有对话框都是有返回值的,返回的是个元祖,第一个元素就是input里对应的内容,第二个元素是个布尔量,如果对话框是按OK则返回1,取消就是返回0.

二.功能作用

  1.构造函数

QInputDialog(self, parent: typing.Optional[QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...)
Window = ...  # type: 'Qt.WindowType'
Dialog = ...  # type: 'Qt.WindowType'
Sheet = ...  # type: 'Qt.WindowType'
Drawer = ...  # type: 'Qt.WindowType'
Popup = ...  # type: 'Qt.WindowType'
Tool = ...  # type: 'Qt.WindowType'
ToolTip = ...  # type: 'Qt.WindowType'
SplashScreen = ...  # type: 'Qt.WindowType'
Desktop = ...  # type: 'Qt.WindowType'
SubWindow = ...  # type: 'Qt.WindowType'
WindowType_Mask = ...  # type: 'Qt.WindowType'
MSWindowsFixedSizeDialogHint = ...  # type: 'Qt.WindowType'
MSWindowsOwnDC = ...  # type: 'Qt.WindowType'
X11BypassWindowManagerHint = ...  # type: 'Qt.WindowType'
FramelessWindowHint = ...  # type: 'Qt.WindowType'
CustomizeWindowHint = ...  # type: 'Qt.WindowType'
WindowTitleHint = ...  # type: 'Qt.WindowType'
WindowSystemMenuHint = ...  # type: 'Qt.WindowType'
WindowMinimizeButtonHint = ...  # type: 'Qt.WindowType'
WindowMaximizeButtonHint = ...  # type: 'Qt.WindowType'
WindowMinMaxButtonsHint = ...  # type: 'Qt.WindowType'
WindowContextHelpButtonHint = ...  # type: 'Qt.WindowType'
WindowShadeButtonHint = ...  # type: 'Qt.WindowType'
WindowStaysOnTopHint = ...  # type: 'Qt.WindowType'
WindowOkButtonHint = ...  # type: 'Qt.WindowType'
WindowCancelButtonHint = ...  # type: 'Qt.WindowType'
WindowStaysOnBottomHint = ...  # type: 'Qt.WindowType'
WindowCloseButtonHint = ...  # type: 'Qt.WindowType'
MacWindowToolBarButtonHint = ...  # type: 'Qt.WindowType'
BypassGraphicsProxyWidget = ...  # type: 'Qt.WindowType'
WindowTransparentForInput = ...  # type: 'Qt.WindowType'
WindowOverridesSystemGestures = ...  # type: 'Qt.WindowType'
WindowDoesNotAcceptFocus = ...  # type: 'Qt.WindowType'
NoDropShadowWindowHint = ...  # type: 'Qt.WindowType'
WindowFullscreenButtonHint = ...  # type: 'Qt.WindowType'
ForeignWindow = ...  # type: 'Qt.WindowType'
BypassWindowManagerHint = ...  # type: 'Qt.WindowType'
CoverWindow = ...  # type: 'Qt.WindowType'
MaximizeUsingFullscreenGeometryHint = ...  # type: 'Qt.WindowType'
flag对应的枚举值

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案