Reputation: 455
I am trying to implement a simple dialog to edit some part of code. I use this which is based on QPlainTextEdit. However, I cannot insert tab into code text. The main reason could be that I show the Code editor as dialog as seen in the code. When I press Tab button the dialog closes and then reopens.
CodeEditor* editor = new CodeEditor(this);
editor->setWindowFlags(Qt::Dialog);
editor->setMinimumSize(400, 400);
editor->show();
Upvotes: 2
Views: 1307
Reputation: 455
Thanks guys,
I solved the problem and it is totally about the part I did not mention in the question. This code is part of qtpropertybrowser code base. I am trying to add a property editor which will open code editing widget I pointed out in the question. When I drill down the qt property code base, I found that tab key is neglected because, it is filtered by eventFilter. When I change this part. I solved the problem.
but, I couldn't solve the problem that the editor is closed and reopened. It becomes so quick. And and error message is outputted as follows QWidget::setTabOrder: 'first' and 'second' must be in the same window.
Upvotes: 4
Reputation: 25155
I would embed the editor in a QDialog with OK and Cancel buttons. Also, make sure that QPlainTextEdit::tabChangesFocus() is false.
Upvotes: 0
Reputation: 19870
Try using Qt::Window
instead of Qt::Dialog
and make it application modal by using QWidget::setWindowModality()
.
Upvotes: 0