I want to retrieve the char as and when they are entered in the QTextedit box. can anyone help me how to do it? plz specify some relevant code if possible.
Thanks
Printable View
I want to retrieve the char as and when they are entered in the QTextedit box. can anyone help me how to do it? plz specify some relevant code if possible.
Thanks
Hi Shuchi,
Do the following:
Code:
in header file protected: private: QTextEdit * m_pTxBox; in cpp file: in constructor: m_pTxBox->installEventFilter(this); { if (target == m_pTxBox) { { std::string str = keyEvent->text().toStdString(); char ch = str[0]; emit keyPressed(ch); // emit signal keyPressed with char entered } } }
or you can make your own class like:
Hi Shuchi,
Is your problem solved? Which one you used?
installEventFilter or reimplementation of keyPressEvent?
Or your problem was something else?
Regards
Rajesh
hi,
i simply fetched the last char of the string returned by "toPlainText()".
but thanks for ur reply.