I'm working on a source code editor in C++, using Qt5 and QScintilla as framework. In this project, I want to continously show the row and column of the text cursor (cursor position), so I need a SIGNAL that emmits whenever the text cursor is moved. According to QScintilla docs, cursorPositionChanged(int line, int index) emmits the wanted signal whenever the cursor is moved, so I guess this must be the method that I need? This is what I did so far:
// notify if cursor position changed
connect(textEdit, SIGNAL(cursorPositionChanged(int line, int index)), this, SLOT(showCurrendCursorPosition()));
my code compiles and the editor window shows up as wanted, but unfortunately, I got the warning:
QObject::connect: No such signal QsciScintilla::cursorPositionChanged(int line, int index)
Can someone please provide me with a QScintilla C++ or Python example showing how to continously get and display the current cursor position?
Complete source code is hosted here: https://github.com/mbergmann-sh/qAmigaED
Thanks for any hints!
The problem is caused by the old syntax of connection that is verified in runtime, in addition that old syntax has as another problem that have to match the signatures. In your case the solution is to use the new connection syntax that does not have the problems you mention.
connect(textEdit, &QTextEdit::cursorPositionChanged, this, &MainWindow::showCurrendCursorPosition);
For more information you can check: