IEditor 类

class Core::IEditor

IEditor 类提供了在 Qt Creator 中编辑打开文档的接口。 更多...

头文件 #include <coreplugin/editormanager/ieditor.h>
继承 Core::IContext

公共函数

IEditor()
virtual intcurrentColumn() const
virtual intcurrentLine() const
virtual Core::IDocument *document() const = 0
virtual Core::IEditor *duplicate()
boolduplicateSupported() const
virtual voidgotoLine(int line, int column = 0, bool centerLine = true)
virtual boolisDesignModePreferred() const
virtual voidrestoreState(const QByteArray &state)
virtual QByteArraysaveState() const
voidsetDuplicateSupported(bool duplicatesSupported)
virtual QWidget *toolBar() = 0

详细描述

IEditor 实例通常由相应的 IEditorFactory 创建。

IEditor 实例通过 IContext::widget() 方法提供了一个单独的 IDocument 编辑器小部件。如果编辑器类型支持,则可以针对同一文档打开多个编辑器。在这种情况下,多个 IEditor 实例共享相同的 IDocument 实例。

IEditor::toolBar() 集成在编辑器小部件上方的工具栏中,位于文档下拉菜单旁边。

另请参阅Core::IEditorFactoryCore::EditorManager

成员函数说明

IEditor::IEditor()

创建一个 IEditor。

实现必须创建一个相应的文档,或者与其他 IEditor 共享现有文档。

[虚拟] int IEditor::currentColumn() const

如果适当,返回文档中的当前列。默认实现返回 0。列号从 0 开始计算,为首列。

另请参阅currentLine() 和 gotoLine

[虚拟] int IEditor::currentLine() const

如果适当,返回文档中的当前行。默认实现返回 0。行号从 1 开始计算,为首行。

另请参阅currentColumn() 和 gotoLine

[纯虚] Core::IDocument *IEditor::document() const

返回由本编辑器编辑的文档。编辑器拥有文档。如果编辑器支持分割,所有使用duplicate()()创建的编辑器都共享文档的所有权。

此方法绝不能返回 nullptr

[虚拟] Core::IEditor *IEditor::duplicate()

返回编辑器的副本,例如当用户分割编辑器视图时。默认实现返回nullptr

另请参阅 duplicateSupported()。

bool IEditor::duplicateSupported() const

返回是否支持复制,例如当用户分割编辑器视图时。

另请参阅 duplicate()和setDuplicateSupported()。

[虚拟] void IEditor::gotoLine(int line, int column = 0, bool centerLine = true)

跳转到文档中的linecolumn。如果centerLinetrue,则在编辑器中居中该行。

行号从第一行的1开始,列号从第一列的0开始。

默认实现不做任何事情。

另请参阅 currentLine()和currentColumn()。

[虚拟] bool IEditor::isDesignModePreferred() const

返回是否默认以设计模式打开文档。这需要设计模式支持该文档类型。默认实现返回false

[虚拟] void IEditor::restoreState(const QByteArray &state)

恢复编辑器的state。默认实现不做任何事情。

另请参阅 saveState

[虚拟] QByteArray IEditor::saveState() const

返回编辑器的状态,如滚动和光标位置,作为一个QByteArray。这用于在例如在文档关闭后(手动或自动)重新打开时恢复状态。默认实现返回一个空的QByteArray

另请参阅 restoreState

void IEditor::setDuplicateSupported(bool duplicatesSupported)

将复制设置为duplicatesSupported

默认为false

另请参阅 duplicateduplicateSupported

[纯虚拟] QWidget *IEditor::toolBar()

返回编辑器的工具栏。

编辑器工具栏位于编辑器视图的顶部。编辑器工具栏是上下文相关的,并显示与编辑器中当前打开的文档相关的项目。

版权所有2024 The Qt Company Ltd. 本文档中包含的贡献者是各自所有者的版权。提供的文档是根据自由软件基金会发布的GNU自由文档许可证版本1.3许可的。Qt及其相关标志是芬兰和其他国家/地区的Qt公司的商标。所有其他商标均为其各自所有者的财产。