PDA

View Full Version : QTextEdit and Form Feed character



gvlaovic
13th September 2007, 19:07
Is there a way to input a form feed character (0x0C) into a QTextEdit? I have tried <CTRL>+L and it doesn't work, even though <CTRL> seems to work for other control characters, such as <CTRL>+I.

jpn
15th September 2007, 12:37
Did you try inserting the character by hand? Does it get rendered as you want? Not that QTextEdit would support all of them, but I suppose that shortcut is not even listed in the list of standard shortcuts (http://doc.trolltech.com/latest/qkeysequence#standard-shortcuts). I guess you could map a set of custom shortcuts even without subclassing QTextEdit like this:


QSignalMapper* mapper = new QSignalMapper(textEdit);
QShortcut* shortcut = new QShortcut(QKeySequence("Ctrl+L"), textEdit);
mapper->setMapping(shortcut, QChar(0x09));
connect(shortcut, SIGNAL(activated()), mapper, SLOT(map()));
connect(mapper, SIGNAL(mapped(QString)), textEdit, SLOT(insertPlainText(QString)));