Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在富文本编辑器中更改列表的字体大小:列表点滑开_Html_Qt_Pyqt4 - Fatal编程技术网

Html 在富文本编辑器中更改列表的字体大小:列表点滑开

Html 在富文本编辑器中更改列表的字体大小:列表点滑开,html,qt,pyqt4,Html,Qt,Pyqt4,在带有html的qtextedit中,我通过鼠标滚轮更改字体大小。 它应该更改每个字符的大小,例如+1或-1。 它起作用了,很慢,但它起作用了。现在的问题是,如果我更改html列表(通过QTextCursor.createList()创建)的大小。如图所示,调整大小后的“测试”总是在相同的位置开始(如预期),但黑点会移动。我希望他们保持在同一个位置,不管文本有多大。我不知道该怎么做,我已经试过setMarging,setIndent,setxtindent def change_fontsize

在带有html的qtextedit中,我通过鼠标滚轮更改字体大小。 它应该更改每个字符的大小,例如+1或-1。 它起作用了,很慢,但它起作用了。现在的问题是,如果我更改html列表(通过QTextCursor.createList()创建)的大小。如图所示,调整大小后的“测试”总是在相同的位置开始(如预期),但黑点会移动。我希望他们保持在同一个位置,不管文本有多大。我不知道该怎么做,我已经试过setMarging,setIndent,setxtindent

def change_fontsize(self, direction):
    cur=self.textedit.textCursor()
    oldPosition=cur.position()

    if cur.hasSelection():
        begin=cur.anchor()
        end=cur.position()
        if begin>end:
            helper=end
            end=begin
            begin=helper
    else:
        cur.select(QTextCursor.Document)
        begin=0
        plainText=self.textedit.toPlainText()
        end=len(plainText)

    for i in range(begin,end):
        cur.setPosition(i)
        cur.movePosition(QTextCursor.NextCharacter, QTextCursor.KeepAnchor)
        fmt=cur.charFormat()
        charSize=fmt.fontPointSize()
        if direction=="up":
            fmt.setFontPointSize(charSize+1)
        else:
            fmt.setFontPointSize(charSize-1)
        cur.mergeCharFormat(fmt)