PDA

View Full Version : Something like putting dash every new line in QTextEdit



kornicameister
5th February 2011, 13:35
I once saw the thread here where someone was looking for something similar like formatting text on fly.

What I want to achieve is to detect whenever 'Enter' is clicked and start new line with the dash at it's beginning ? What I really want to achieve is TODO list :)

I can not find this thread and I do know which class could be used to achieve my goal.

probably QTextCursor may help here, will see.
Scenario like this maybe
1. connect textChanged() signal
2. using QTextCursor check code of the last entered char
3. if it is new line code than put new line and start new line with dash ?

No I failed to came up with something working use the scenario above

nirva
5th February 2011, 21:04
There are several possibilities. Maybe you could just use QTextEdit::AutoBulletList as the formatting mode. Or if that's not enough,
subclass QTextEdit and reimplement keyPressEvent(), then add the dash whenever the return key is pressed.

kornicameister
5th February 2011, 23:08
I found it before I read your reply, thanks anyway :)
But now I am thinking how to insert first dot using the code only