Qt 中QTextEdit、QPlainTextEdit中的anchorAt方法的用途是什么?

QTextEdit、QPlainTextEdit中的anchorAt方法官网说是返回指向参数point所在的anchor,请问这儿的anchor与textCursor中的anchor是一样的吗?怎么访问?本人如下一段PyQt的代码怎么都返回的是no anchor?具体代码如下:

def test(self,point):
    cursor = self.plainTextEdit.textCursor():
    pos = cursor.position()
    
    if not self.anchor:
        cursor.setPositio(5)
        self.anchor = 1
        print('anchor:', cursor.position(),cursor.anchor())
    else:
        ret = cursor.setPositio(30,QtCui.QTextCursor.keepAnchor)
        print('anchor:', cursor.position(),cursor.anchor())
        self.anchor +=1
        for x in range(470):
            for y in range(20):
                inf = self.plainTextEdit.anchorAt(QtCore.QPoint(x,y))
                if inf:break;
            if inf:print(inf)
            else:print(point,'no anchor') 
        
python
188 views
Comments
登录后评论
Sign In