Unable to write in QTextEdit
I wrote new class inherited from QTextEdit and have keypressevent inside my class called "MyTextEdit.cpp"
Now I want to use this in other class called "MyEditor.cpp", so i created an object of MyTextEdit class and set the setReadOnly() property to false. But it not allow me to write in textedit. I also set it to setEnabled() to true. But still facing same issue.
I think i am missing something or made some silly mistake.
Can anyone let me know what i am doing wrong here.
Re: Unable to write in QTextEdit
In your keyPressEvent() method, do you call the base class implementation?
Cheers,
_
Re: Unable to write in QTextEdit
Yah, but textedit itself not writable, although I can call my kerypressevent, which is not an issue. Issue is i not even get textEdit as writable/editable.
Re: Unable to write in QTextEdit
What you are describing is captured below:
Code:
#include <QApplication>
#include <QTextEdit>
#include <QDebug>
{
Q_OBJECT
public:
protected:
// do local stuff
qDebug() << "Doing local stuff";
// then do the base stuff
}
};
int main(int argc, char **argv) {
MyTextEdit edit; // defaults to editable
edit.show();
return app.exec();
}
#include "main.moc"
and this works. So, is this what you are doing?
Re: Unable to write in QTextEdit
yah thanks.
But what you explained, I previously done same thing. And it works if it is as standalone program. But when I do same thing in my application , its not work. and not allows me to edit or write ?? :(
Added after 1 14 minutes:
THANKS TO BOTH OF YOU :) to suggest me some solution.
But I figure out it. I don't know the exact issue, but i tried to re-write my code, it got worked.
Really a Wiered one. In end it got work. lol