> I am afraid I don't understand
Editing cell with default delegate:
When I insert a new row in TableView (the new row gets "*" mark) and the cell is varchar(), I get standard delegate behaving like QLineEdit. After inputing the text I can
- press TAB to move to next cell in the row (the "*" stays unchagned), or
- press Enter/Return after which the row commits (the "*" changes to numeric row sequence) and the focus stays on current cell, the cell is selected.
Editing cell with default my custom delegate (using QPlainTextEdit).
When I insert a new row, and start editing a cell with my custom delegate, the row is marked "*", I want similar behaviour as above:
1) pressing TAB should move focus to next cell (the row mark should stay "*")
2) pressing Control+Enter should move focus commit row ("*" row mark should change to numeric) and focus should stay on the current cell and cell should be selected.
I manage to figure out 1) by calling QPlainTextEdit->setTabChangesFocus(true)
I dont know how to achive 2)
I did subclass QPlainTextEdit with keyPressEvent() member so I can see all keys being sent.
I am intercepting Key_Tab, or (Ctrl+Enter), but I dont know what code should I call to achive 2) behaviour
I dont know what the code of QPlainTextEdit does to achive 1) when I call QPlainTextEdit->setTabChangesFocus(true); I would like to do similar for other key sequences.
THis is what I have now
class myMultiLineEdit : public QPlainTextEdit
{
public:
myMultiLineEdit
(QWidget * parent
) : QPlainTextEdit
(parent
) {} {
if(ee->key() == Qt::Key_Tab)
{
qDebug() << "tab pressed";
focusNextChild() || focusPreviousChild();
}
else
QPlainTextEdit::keyPressEvent(ee);
}
};
class myMultiLineEdit : public QPlainTextEdit
{
public:
myMultiLineEdit (QWidget * parent) : QPlainTextEdit(parent) {}
virtual void keyPressEvent(QKeyEvent *ee)
{
if(ee->key() == Qt::Key_Tab)
{
qDebug() << "tab pressed";
focusNextChild() || focusPreviousChild();
}
else
QPlainTextEdit::keyPressEvent(ee);
}
};
To copy to clipboard, switch view to plain text mode
but focusNextChild() || focusPreviousChild() does nothing, the editor control does not close and does not move to next cell.
cheers
Bookmarks