QDesignerFormWindowCursorInterface Class

QDesignerFormWindowCursorInterface 类允许您查询和修改表单窗口的部件选择,以及修改表单所有部件的属性。更多

Header: #include <QDesignerFormWindowCursorInterface>
CMake: find_package(Qt6 REQUIRED COMPONENTS Designer)
target_link_libraries(mytarget PRIVATE Qt6::Designer)
qmake: QT += designer

公共类型

enum MoveMode { MoveAnchor, KeepAnchor }
enum MoveOperation { NoMove, Start, End, Next, Prev, …, Down }

公共函数

virtual ~QDesignerFormWindowCursorInterface()
virtual QWidget *current() const = 0
virtual QDesignerFormWindowInterface *formWindow() const = 0
virtual bool hasSelection() const = 0
bool isWidgetSelected(QWidget *widget) const
virtual bool movePosition(QDesignerFormWindowCursorInterface::MoveOperation operation, QDesignerFormWindowCursorInterface::MoveMode mode = MoveAnchor) = 0
virtual int position() const = 0
virtual void resetWidgetProperty(QWidget *widget, const QString &name) = 0
virtual QWidget *selectedWidget(int index) const = 0
virtual int selectedWidgetCount() const = 0
virtual void setPosition(int position, QDesignerFormWindowCursorInterface::MoveMode mode = MoveAnchor) = 0
virtual void setProperty(const QString &name, const QVariant &value) = 0
virtual void setWidgetProperty(QWidget *widget, const QString &name, const QVariant &value) = 0
virtual QWidget *widget(int index) const = 0
virtual int widgetCount() const = 0

详细说明

QDesignerFormWindowCursorInterface 是一个方便使用的类,它为相关窗体窗口的文本光标提供了一个接口;它提供了一系列函数,使您可以查询给定窗体窗口的选区,并根据定义的模式 (MoveMode) 和移动 (MoveOperation) 改变选区的焦点。您还可以使用该界面查询表单窗口部件并更改其属性。

Qt Widgets Designer QDesignerFormWindowInterface 总是提供一个相关的光标接口。可以使用静态 () 函数检索给定 widget 的窗体窗口。例如QDesignerFormWindowInterface::findFormWindow

    auto *formWindow = QDesignerFormWindowInterface::findFormWindow(myWidget);

    formWindow->cursor()->setProperty(myWidget, myProperty, newValue);

您可以通过Qt Widgets Designerform window manager 获取Qt Widgets Designer 的任何当前窗体窗口。

有了窗体窗口的光标界面后,就可以使用hasSelection() 函数检查窗体窗口是否有选区。您可以查询表单窗口的总widgetCount() 和selectedWidgetCount() 。可以使用current() 或selectedWidget() 函数获取当前选定的一个(或多个)部件。

您可以使用widget() 函数检索表单窗口的任何部件,并使用isWidgetSelected() 函数检查是否选中了某个部件。您可以使用setProperty() 函数设置选中部件的属性,使用setWidgetProperty() 或resetWidgetProperty() 函数修改任何给定部件的属性。

最后,您可以通过使用setPosition() 和movePosition() 函数更改文本光标的position() 来改变选择。

另请参阅 QDesignerFormWindowInterfaceQDesignerFormWindowManagerInterface

成员类型文档

enum QDesignerFormWindowCursorInterface::MoveMode

该枚举描述了文本光标移动时使用的不同模式。

常量说明
QDesignerFormWindowCursorInterface::MoveAnchor0锚点随光标移动到新位置。
QDesignerFormWindowCursorInterface::KeepAnchor1锚点停留在光标的旧位置。

enum QDesignerFormWindowCursorInterface::MoveOperation

该枚举描述了表单窗口中可能出现的文本光标操作类型。

常数说明
QDesignerFormWindowCursorInterface::NoMove0光标不移动。
QDesignerFormWindowCursorInterface::Start1将光标移动到焦点链的起点。
QDesignerFormWindowCursorInterface::End2将光标移至焦点链的末端。
QDesignerFormWindowCursorInterface::Next3将光标移至焦点链中的下一个部件。
QDesignerFormWindowCursorInterface::Prev4将光标移到焦点链中的上一个部件。
QDesignerFormWindowCursorInterface::Left5光标向左移动。
QDesignerFormWindowCursorInterface::Right6光标向右移动。
QDesignerFormWindowCursorInterface::Up7光标向上移动。
QDesignerFormWindowCursorInterface::Down8光标向下移动

成员函数文档

[virtual constexpr noexcept] QDesignerFormWindowCursorInterface::~QDesignerFormWindowCursorInterface()

销毁光标界面。

[pure virtual] QWidget *QDesignerFormWindowCursorInterface::current() const

返回表单窗口中当前选中的部件。

另请参阅 selectedWidget()。

[pure virtual] QDesignerFormWindowInterface *QDesignerFormWindowCursorInterface::formWindow() const

返回与该光标界面相关的表单窗口界面。

[pure virtual] bool QDesignerFormWindowCursorInterface::hasSelection() const

如果表格窗口包含一个选区,则返回 true;否则返回 false。

bool QDesignerFormWindowCursorInterface::isWidgetSelected(QWidget *widget) const

如果选择了指定的widget ,则返回 true;否则返回 false。

[pure virtual] bool QDesignerFormWindowCursorInterface::movePosition(QDesignerFormWindowCursorInterface::MoveOperation operation, QDesignerFormWindowCursorInterface::MoveMode mode = MoveAnchor)

使用指定的mode 在游标上执行给定的operation ,如果成功完成则返回 true,否则返回 false。

另请参阅 position() 和setPosition() 。

[pure virtual] int QDesignerFormWindowCursorInterface::position() const

返回光标位置。

另请参阅 setPosition() 和movePosition()。

[pure virtual] void QDesignerFormWindowCursorInterface::resetWidgetProperty(QWidget *widget, const QString &name)

将指定widget 的给定name 的属性重置为默认值。

另请参阅 setProperty() 和setWidgetProperty()。

[pure virtual] QWidget *QDesignerFormWindowCursorInterface::selectedWidget(int index) const

返回所选部件列表中带有给定index 的部件。

另请参阅 current() 和widget()。

[pure virtual] int QDesignerFormWindowCursorInterface::selectedWidgetCount() const

返回表单窗口中所选部件的数量。

另请参阅 widgetCount()。

[pure virtual] void QDesignerFormWindowCursorInterface::setPosition(int position, QDesignerFormWindowCursorInterface::MoveMode mode = MoveAnchor)

使用mode 指定光标的移动方式,将光标的位置设置为给定的position

另请参阅 position() 和movePosition()。

[pure virtual] void QDesignerFormWindowCursorInterface::setProperty(const QString &name, const QVariant &value)

将当前选定部件的属性(给定的name )设置为指定的value

另请参阅 setWidgetProperty() 和resetWidgetProperty()。

[pure virtual] void QDesignerFormWindowCursorInterface::setWidgetProperty(QWidget *widget, const QString &name, const QVariant &value)

将给定widget 的给定name 属性设置为指定的value 属性。

另请参阅 resetWidgetProperty() 和setProperty()。

[pure virtual] QWidget *QDesignerFormWindowCursorInterface::widget(int index) const

返回表单窗口中部件列表中带有给定index 的部件。

另请参阅 selectedWidget()。

[pure virtual] int QDesignerFormWindowCursorInterface::widgetCount() const

返回表单窗口中部件的数量。

另请参见 selectedWidgetCount()。

© 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.