QDesignerFormWindowCursorInterface Class
QDesignerFormWindowCursorInterface 类允许您查询和修改表单窗口的小部件选择,此外还可以修改该表单中所有小部件的属性。更多内容...
| 标题: | #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 } |
公共函数
| QDesignerFormWindowCursorInterface() | |
| QDesignerFormWindowCursorInterface(const QDesignerFormWindowCursorInterface &) | |
| QDesignerFormWindowCursorInterface(QDesignerFormWindowCursorInterface &&) | |
| 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 & | operator=(QDesignerFormWindowCursorInterface &&) |
| QDesignerFormWindowCursorInterface & | operator=(const QDesignerFormWindowCursorInterface &) |
详细说明
QDesignerFormWindowCursorInterface 是一个便利类,它为关联表单窗口的文本光标提供了一个接口;该类提供了一组函数,允许您查询给定表单窗口的选区,并根据定义的模式(MoveMode )和移动方式(MoveOperation )更改选区的焦点。 您还可以使用该接口查询表单的控件并修改其属性。
该接口并非用于直接实例化,而是为了访问 `Qt Widgets Designer` 当前表单窗口中的选区和控件。`QDesignerFormWindowInterface ` 始终提供一个关联的光标接口。可以通过静态函数 `QDesignerFormWindowInterface::findFormWindow()` 获取给定控件对应的表单窗口。例如:
auto *formWindow = QDesignerFormWindowInterface::findFormWindow(myWidget);
formWindow->cursor()->setProperty(myWidget, myProperty, newValue);您可以通过Qt Widgets Designer 的form window manager 获取Qt Widgets Designer 的任何当前表单窗口。
一旦获得了表单窗口的光标接口,即可使用hasSelection() 函数检查该表单窗口是否存在选中项。您可以通过widgetCount() 和selectedWidgetCount() 查询表单窗口的总元素数。使用current() 或selectedWidget() 函数可获取当前选中的控件(或多个控件)。
您可以使用widget() 函数获取表单窗口中的任意控件,并使用isWidgetSelected() 函数检查某个控件是否被选中。您可以使用setProperty() 函数设置所选控件的属性,并使用setWidgetProperty() 或resetWidgetProperty() 函数修改任意给定控件的属性。
最后,您可以通过setPosition()和movePosition()函数,修改文本光标的position()来更改选中内容。
另请参阅 QDesignerFormWindowInterface 和QDesignerFormWindowManagerInterface 。
成员类型文档
enum QDesignerFormWindowCursorInterface::MoveMode
此枚举描述了文本光标移动时使用的不同模式。
| 常量 | 值 | 描述 |
|---|---|---|
QDesignerFormWindowCursorInterface::MoveAnchor | 0 | 锚点随光标一起移动到新位置。 |
QDesignerFormWindowCursorInterface::KeepAnchor | 1 | 锚点保留在光标原位置。 |
enum QDesignerFormWindowCursorInterface::MoveOperation
此枚举描述了表单窗口中可能发生的文本光标操作类型。
| 常量 | 值 | 描述 |
|---|---|---|
QDesignerFormWindowCursorInterface::NoMove | 0 | 光标不移动。 |
QDesignerFormWindowCursorInterface::Start | 1 | 将光标移至焦点链的开头。 |
QDesignerFormWindowCursorInterface::End | 2 | 将光标移动到焦点链的末尾。 |
QDesignerFormWindowCursorInterface::Next | 3 | 将光标移至焦点链中的下一个控件。 |
QDesignerFormWindowCursorInterface::Prev | 4 | 将光标移至焦点链中的上一个控件。 |
QDesignerFormWindowCursorInterface::Left | 5 | 光标向左移动。 |
QDesignerFormWindowCursorInterface::Right | 6 | 光标向右移动。 |
QDesignerFormWindowCursorInterface::Up | 7 | 光标向上移动。 |
QDesignerFormWindowCursorInterface::Down | 8 | 光标向下移动。 |
成员函数文档
[constexpr noexcept default] QDesignerFormWindowCursorInterface::QDesignerFormWindowCursorInterface()
默认——构造一个QDesignerFormWindowCursorInterface 的实例。
[delete] QDesignerFormWindowCursorInterface::QDesignerFormWindowCursorInterface(const QDesignerFormWindowCursorInterface &)
复制并构造一个QDesignerFormWindowCursorInterface 实例。该函数已被删除。
[delete] QDesignerFormWindowCursorInterface::QDesignerFormWindowCursorInterface(QDesignerFormWindowCursorInterface &&)
通过Move构造一个QDesignerFormWindowCursorInterface 的实例。该函数已被删除。
[virtual constexpr noexcept default] 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 的控件。
[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()。
[delete] QDesignerFormWindowCursorInterface &QDesignerFormWindowCursorInterface::operator=(QDesignerFormWindowCursorInterface &&)
将other 按移动赋值方式赋值给此QDesignerFormWindowCursorInterface 实例。该函数已被删除。
[delete] QDesignerFormWindowCursorInterface &QDesignerFormWindowCursorInterface::operator=(const QDesignerFormWindowCursorInterface &)
将other 复制并赋值给此QDesignerFormWindowCursorInterface 实例。该函数已被删除。
© 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.