Core::IEditor Class
class Core::IEditorIEditor 类为在Qt Creator 中编辑已打开的文档提供了一个接口。更多内容...
| Header: | #include <coreplugin/editormanager/ieditor.h> |
| Inherits: | Core::IContext |
公共函数
| IEditor() | |
| virtual int | currentColumn() const |
| virtual int | currentLine() const |
| virtual Core::IDocument * | document() const = 0 |
| virtual Core::IEditor * | duplicate() |
| bool | duplicateSupported() const |
| virtual void | gotoLine(int line, int column = 0, bool centerLine = true) |
| virtual bool | isDesignModePreferred() const |
| virtual void | restoreState(const QByteArray &state) |
| virtual QByteArray | saveState() const |
| void | setDuplicateSupported(bool duplicatesSupported) |
| virtual QWidget * | toolBar() = 0 |
详细说明
IEditor 实例通常由相应的IEditorFactory 创建。
一个 IEditor 实例通过IContext::widget() 方法为单个IDocument 提供一个编辑器控件。如果编辑器类型支持,可以为同一文档打开多个编辑器。在这种情况下,多个 IEditor 实例共享同一个IDocument 实例的所有权。
IEditor::toolBar() 已集成到编辑器控件上方的工具栏中,位于文档下拉菜单旁边。
另请参阅 Core::IEditorFactory 和Core::EditorManager 。
成员函数文档
IEditor::IEditor()
创建一个 IEditor。
实现类必须创建相应的文档,或者与另一个 IEditor 共享现有文档。
[virtual] int IEditor::currentColumn() const
返回文档中的当前列(如果适用)。默认实现返回0 。列编号从0 开始,其中 表示第一列。
另请参阅 currentLine() 和gotoLine()。
[virtual] int IEditor::currentLine() const
返回文档中的当前行(如果适用)。默认实现返回0 。第一行的行号从1 开始。
另请参阅 currentColumn() 和gotoLine()。
[pure virtual] Core::IDocument *IEditor::document() const
返回由该编辑器编辑的文档。该编辑器拥有该文档的所有权。如果编辑器支持拆分,则所有通过 `duplicate()` 创建的编辑器将共同拥有该文档的所有权。
此方法绝不能返回 `nullptr`。
[virtual] Core::IEditor *IEditor::duplicate()
返回编辑器的副本,例如当用户拆分编辑器视图时。默认实现返回nullptr 。
另请参阅 duplicateSupported()。
bool IEditor::duplicateSupported() const
返回是否支持复制,例如当用户拆分编辑器视图时。
另请参阅 duplicate() 和setDuplicateSupported()。
[virtual] void IEditor::gotoLine(int line, int column = 0, bool centerLine = true)
在文档中跳转至line 和column 。如果centerLine 的值是true ,则将该行在编辑器中居中显示。
行号从1 开始计数(第一行),列号从0 开始计数(第一列)。
默认实现不执行任何操作。
另请参见 currentLine() 和currentColumn()。
[virtual] bool IEditor::isDesignModePreferred() const
返回该文档是否应默认以设计模式打开。这需要设计模式支持该文档类型。默认实现返回false 。
[virtual] void IEditor::restoreState(const QByteArray &state)
恢复编辑器的state 。默认实现不执行任何操作。
另请参阅 saveState()。
[virtual] QByteArray IEditor::saveState() const
返回编辑器的状态(如滚动和光标位置),格式为QByteArray 。这用于在文档关闭(手动或自动)后再次打开时恢复其状态。默认实现返回一个空的QByteArray 。
另请参阅 ` restoreState()`。
void IEditor::setDuplicateSupported(bool duplicatesSupported)
将是否支持复制设置为duplicatesSupported 。
默认值为false 。
另请参阅 duplicate() 和duplicateSupported()。
[pure virtual] QWidget *IEditor::toolBar()
返回编辑器的工具栏。
编辑器工具栏位于编辑器视图的顶部。该工具栏具有上下文相关性,会显示与当前在编辑器中打开的文档相关的项目。
Copyright © The Qt Company Ltd. and other contributors. 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.