QDesignerFormWindowCursorInterface Class

The QDesignerFormWindowCursorInterface class allows you to query and modify a form window's widget selection, and in addition modify the properties of all the form's widgets. 更多...

头: #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 is a convenience class that provides an interface to the associated form window's text cursor; it provides a collection of functions that enables you to query a given form window's selection and change the selection's focus according to defined modes ( MoveMode ) and movements ( MoveOperation ). You can also use the interface to query the form's widgets and change their properties.

The interface is not intended to be instantiated directly, but to provide access to the selections and widgets of Qt Designer 's current form windows. QDesignerFormWindowInterface always provides an associated cursor interface. The form window for a given widget can be retrieved using the static QDesignerFormWindowInterface::findFormWindow () functions. For example:

    auto *formWindow = QDesignerFormWindowInterface::findFormWindow(myWidget);
    formWindow->cursor()->setProperty(myWidget, myProperty, newValue);
					

You can retrieve any of Qt Designer 's current form windows through Qt Designer 's form window manager .

Once you have a form window's cursor interface, you can check if the form window has a selection at all using the hasSelection () function. You can query the form window for its total widgetCount () 和 selectedWidgetCount (). You can retrieve the currently selected widget (or widgets) using the current () 或 selectedWidget () 函数。

You can retrieve any of the form window's widgets using the widget () function, and check if a widget is selected using the isWidgetSelected () function. You can use the setProperty () function to set the selected widget's properties, and the setWidgetProperty () 或 resetWidgetProperty () functions to modify the properties of any given widget.

Finally, you can change the selection by changing the text cursor's position () 使用 setPosition () 和 movePosition () 函数。

另请参阅 QDesignerFormWindowInterface and QDesignerFormWindowManagerInterface .

成员类型文档编制

enum QDesignerFormWindowCursorInterface:: MoveMode

This enum describes the different modes that are used when the text cursor moves.

常量 描述
QDesignerFormWindowCursorInterface::MoveAnchor 0 The anchor moves with the cursor to its new location.
QDesignerFormWindowCursorInterface::KeepAnchor 1 The anchor remains at the cursor's old location.

enum QDesignerFormWindowCursorInterface:: MoveOperation

This enum describes the types of text cursor operation that can occur in a form window.

常量 描述
QDesignerFormWindowCursorInterface::NoMove 0 The cursor does not move.
QDesignerFormWindowCursorInterface::Start 1 Moves the cursor to the start of the focus chain.
QDesignerFormWindowCursorInterface::End 2 Moves the cursor to the end of the focus chain.
QDesignerFormWindowCursorInterface::Next 3 Moves the cursor to the next widget in the focus chain.
QDesignerFormWindowCursorInterface::Prev 4 Moves the cursor to the previous widget in the focus chain.
QDesignerFormWindowCursorInterface::Left 5 The cursor moves to the left.
QDesignerFormWindowCursorInterface::Right 6 The cursor moves to the right.
QDesignerFormWindowCursorInterface::Up 7 The cursor moves upwards.
QDesignerFormWindowCursorInterface::Down 8 The cursor moves downwards.

成员函数文档编制

[虚拟] QDesignerFormWindowCursorInterface:: ~QDesignerFormWindowCursorInterface ()

Destroys the cursor interface.

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

Returns the currently selected widget in the form window.

另请参阅 selectedWidget ().

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

Returns the form window interface associated with this cursor interface.

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

Returns true if the form window contains a selection; otherwise returns false.

bool QDesignerFormWindowCursorInterface:: isWidgetSelected ( QWidget * widget ) const

返回 true 若指定 widget is selected; otherwise returns false.

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

Performs the given operation on the cursor using the specified mode , and returns true if it completed successfully; otherwise returns false.

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

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

返回光标位置。

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

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

Resets the property with the given name 为指定 widget to its default value.

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

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

Returns the widget with the given index in the list of selected widgets.

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

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

Returns the number of selected widgets in the form window.

另请参阅 widgetCount ().

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

Sets the position of the cursor to the given position 使用 mode to specify how it is moved there.

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

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

Sets the property with the given name for the currently selected widget to the specified value .

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

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

Sets the property with the given name 为给定 widget 到指定 value .

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

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

Returns the widget with the given index in the list of widgets in the form window.

另请参阅 selectedWidget ().

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

Returns the number of widgets in the form window.

另请参阅 selectedWidgetCount ().