Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.9.1
-
None
-
Windows 7 x64, MinGW 5.3 & 6.3 & 7.2
Description
I found myself in a situation that called for more control over the text cursor in QML, which was only part of the private API, thus I decided to do a quick and dirty exposing by overriding the class:
// with quick-private in the PRO file #include <QtQuick/private/qquicktextedit_p.h> #include <QtQuick/private/qquicktextedit_p_p.h> #include <QtQuick/private/qquicktextcontrol_p.h> class CTextEdit : public QQuickTextEdit { Q_OBJECT public: CTextEdit(QQuickItem * p = 0) : QQuickTextEdit(p) {} public slots: void cursorOp(int mode) { QQuickTextEditPrivate * ep = reinterpret_cast<QQuickTextEditPrivate *>(d_ptr.data()); QTextCursor c = ep->control->textCursor(); c.movePosition((QTextCursor::MoveOperation)mode); ep->control->setTextCursor(c); } };
Which turned out to work perfectly, however, there are some problems with getting that code to build. I was getting the following errors:
moc_extra.cpp:-1: error: undefined reference to `QQuickTextControl::textCursor() const' moc_extra.cpp:-1: error: undefined reference to `QQuickTextControl::setTextCursor(QTextCursor const&)'
Which is not true, because that's a stock Qt class that most certainly implements that functionality.
A user on the Qt forums where I posted this problem informed me that it builds for him, on his build from source.
I eventually managed to get it to build, but only on a custom statically linked Qt build, with literally the same configuration save for the -static option still results in the same undefined reference errors.
I also tried to build that code in an empty project, presuming it may succeed outside of a big and complex project, still no luck.
I also tried the stock Android build, which too failed because of those few lines, but rather than undefined reference errors, I got a:
collect2.exe:-1: error: error: ld returned 1 exit status
Which is definitely caused by those few lines of code, because commenting them out results in a successful build.
So this definitely looks like a bug. Could it have something to do with the deprecation of the declarative module, and its fragmentation into qml and quick?
I did find this bit of documentation, stating that:
All classes that were previously in the QtDeclarative module have been moved into the Qt QML and Qt Quick modules
However, that is either wrong, or applies to a narrow context, for example the classes from the public API.
Nonetheless, even in the Qt builds that fail do build the above code I still have `TextEdit` and the cursor ops definitely work via the keyboard, so that functionality is there, also evident from the fact I did get it to build and work in a static Qt build.
Edit: Being active on SO, I notice other people getting those errors for various private modules too, so it seems it might be a recent issue and a possible regression rather than a problem with a specific class, thus I updated the title to reflect a more general problem.