gruszczy
gruszczy

Reputation: 42228

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 way?

Upvotes: 4

Views: 1652

Answers (1)

Chris
Chris

Reputation: 17545

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()).

Upvotes: 5

Related Questions