サブクラス化されたQTextEditをコーディングして、「Enter」キーを押して「スロット」呼び出しを行う方法は?
//mainwindow.cpp
myTextEdit *mytext = new myTextEdit(this);
mytext->setGeometry(QRect(QPoint(10,20), QSize(100,50)));
connect(mytext, SIGNAL(myReturn()), this, SLOT(handleText()));
//subclassed QTextEdit
void myTextEdit::keyPressEvent(QKeyEvent *e)
{
QString qstr = ::myTextEdit::toPlainText();
if(e->key() == 16777220){ //enter key
qstr = qstr + "\r\n>> ";
//now cause an event like a QPushButton "released()" event to cause a "slot" call
}else{
qstr = qstr + e->key();
}
::myTextEdit::setText(qstr);
}