Hello,

My name is Tim, and I am new to the Qt community.

A few months ago, I started to implement a text editor as a private project.
So, I am working with a QTextEdit.
At the moment, I am adjusting the space between words and individual characters.
This should help to increase the readability of the text.
Please find attached a minimal executable python example and a screenshot as 
well.

I made some observations regarding the cursor.

a) The cursor overlaps with the character.
Is it possible to have the cursor with a margin to the left side?
It would be great to place the cursor at the 'font letter spacing' space.
My goal is to move the cursor between two letters, and it doesn't overlap any 
letter.

b) I can adjust the width of the cursor.
Is there a chance to adjust the height and the color as well?

Maybe somebody can help me out. I am thankful for any pointer.
I don't know if there are low-level functions that I can overwrite :)

Best regards,

Tim :)



[cid:c23075cc-eb1a-4722-a0c6-2931d23b8026@EURP193.PROD.OUTLOOK.COM]
from PyQt5.QtGui import QFont, QTextCursor, QTextCharFormat
from PyQt5.QtWidgets import QTextEdit
from PyQt5 import QtWidgets


def main():
    app = QtWidgets.QApplication([])

    editor = QTextEdit()
    editor.resize(800, 600)
    editor.setFont(QFont("Arial", 60))
    editor.show()

    format = QTextCharFormat()
    format.setFontWordSpacing(10)

    format.setFontLetterSpacingType(QFont.AbsoluteSpacing)
    format.setFontLetterSpacing(10)

    cursor = editor.textCursor()
    cursor.setCharFormat(format)
    cursor.insertText("This is a sentence.")

    editor.setCursorWidth(5)

    cursor = QTextCursor(editor.document())
    cursor.setPosition(6)
    editor.setTextCursor(cursor)

    app.exec_()


if __name__ == "__main__":
    main()
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to