parulkalra14
22nd January 2014, 08:22
I want whenever open parenthesis occurs({) cursor will move to next line and four spaces ahead and this must be recursively done (means when again parenthesis occurs then cursor will again move to next line but now cursor will move eight spaces ahead ). KeyPress Enter Code is working fine but how to compare text parenthesis along with key event?
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::KeyPress){
QKeyEvent *key = static_cast<QKeyEvent*>(event);
if(key && key->key() == Qt::Key_Enter||key && key->key() == Qt::Key_Return)
{
textEdit->insertPlainText("\n\t");
return true;
}
}return false;
}
tabstopwidth is set to 4.
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::KeyPress){
QKeyEvent *key = static_cast<QKeyEvent*>(event);
if(key && key->key() == Qt::Key_Enter||key && key->key() == Qt::Key_Return)
{
textEdit->insertPlainText("\n\t");
return true;
}
}return false;
}
tabstopwidth is set to 4.