qt: intercepting tab character in QTextEdit
I am writing a small editor. I would like to change default behaviour of QTextEdit, that inserts tabs when Tab
is hit. Instead I would like to put 4 spaces. What is the recommended way of doing this? I though about subclassing keyPressedEvent
, but maybe there is some better开发者_StackOverflow way?
My opinion is that subclassing and overriding the keyPressEvent function is the way to go. If for whatever reason you are really adverse to subclassing you could probably use an event filter (see QObject::installEventFilter() and QObject::eventFilter()).
精彩评论