如何通过单击按钮在 QTextEdit 中使用 Qt 创建项目符号或编号列表?此外,还需要列出通过单击同一按钮选择的段落。当光标位于列表中并单击按钮时,列表项变为非列表项,而是一个简单的段落。简而言之,我想为我的文本编辑器创建 2 个按钮,其工作方式与(项目符号和编号按钮是 MS Word)相同。
How to create a bulleted or numbered list in QTextEdit with Qt by clicking a button? Also it is necessary that make a list the paragraphes which are selected by clicking the same button. And when the cursor is in the list and you click the button, the the list item becomes not-list item, but a simple paragraph. In two words I want to create for my text editer 2 buttons, that work in the same way as (buletting and numbering button is MS Word).
发布评论
评论(2)
我使用了这段代码:
来自此来源。
只是我改成
了下面的代码:
I have used this code:
from this source.
Only I have changed
to the following code:
QTextEdit 应支持 html 文本格式,因此下面的按钮单击处理程序应将 2 个列表插入到文本编辑控件中:
或者您可以使用 QTextDocument 和 QTextCursor 成员。下面是一个示例:
还有此链接: 富文本处理 可能会有所帮助
,希望如此帮助,问候
QTextEdit should support html text formatting so button click handler below should insert 2 lists into the text edit control:
alternatively you can manipulate textedit content using QTextDocument and QTextCursor members. Below is an example:
also this link: Rich Text Processing might be helpful
hope this helps, regards