Hello everyone!!
I'm using Qt 3.7 .
I have a class that inherits QTextEdit and I would like to get the position of the text cursor (x() and y()).
I can't use textCursor() function because it's protected.
Do you have any suggestions?
Hello everyone!!
I'm using Qt 3.7 .
I have a class that inherits QTextEdit and I would like to get the position of the text cursor (x() and y()).
I can't use textCursor() function because it's protected.
Do you have any suggestions?
You can access base's protected member functions from within derived class (this will be an issue only if the member is declared private).
I'M CORRECTING MY PREVIOUS MESSAGE
Hello everyone!!
I'm using Qt 3.7 .
I have a class that gets a QTextEdit as a parameter and I would like to get the position of the text cursor (x() and y()).
I can't use textCursor() function because it's protected. (The class inherits a class that inherits QObject)
Do you have any suggestions?
The obvious answer is: derive a class from QTextEdit, into that class code a public member function that returns whatever the textCursor() returns and use this class as parameter.
//Also if possible upgrade to Qt4, in between other improvement textCursor has become a public member.
Thanks for the answer. I'll try that tomorrow
Hello again,
unluckily I couldn't made it.
I've made a subclass that inherits QTextEdit and a public function:
getCursorCoordinates() {
QTextCursor *tc = textCursor();
int x = tc->globalX();
int y = tc->globalY();
}
and I had the error:
request for member 'globalX' in 'tc', which is non-class type 'QTextCursor'.
I think because QTextCursor is a private class.
Any other help? I can't upgrade to Qt4..It's not up to me...
Try to #include <QTextCursor>, this sounds like the compiler could not find the class' definition.
This is not possible. it's a private class
Hello,
I added this header:
#include <private/qrrichtext_p.h>
and it works. Many thanks again!!
Bookmarks