undefined reference to `QQuickTextControl::textCursor() const'
-
I find myself in a situation that I need to tap into the private implementations of a few classes, but the code doesn't compile, complaining about undefined references.
QQuickTextControlis a stock framework class, so it is definitely defined, but for some reason the linker cannot pick it up.I have already added
quick-privateto the PRO file.Is there something else that I need to do to get it to compile?
-
Hi,
From a quick look at Qt's sources, that class comes from the
QtDeclarativemodule. -
@SGaist Hmm, if that's the case how come the header is in
QtQuick/private/qquicktextcontrol_p.h?
Come to think about it, I don't even seem to have the declarative module at all. Besides, if it came from declarative, wouldn't it be named
QDeclarativeTextControlinstead?Anyway, to elaborate a little further on the issue at hand, I want to expose some text cursor operations to QML which are currently not part of the public API, my code is rather simple:
#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); } };Yet I get undefined reference errors for the
controlfunctions:moc_extra.cpp:-1: error: undefined reference to `QQuickTextControl::textCursor() const' moc_extra.cpp:-1: error: undefined reference to `QQuickTextControl::setTextCursor(QTextCursor const&)'So how do I get it to build?
-
What version of Qt are you using ?
-
I've successfully built it with 5.9.2.
-
Nothing special, the only difference I can see is that it's a self-built Qt but that shouldn't matter.
-
Nothing special, the only difference I can see is that it's a self-built Qt but that shouldn't matter.
-
Yes, only with it.
However, I'm not using a static build but that shouldn't change anything.
What platform are you on ?
-
Yes, only with it.
However, I'm not using a static build but that shouldn't change anything.
What platform are you on ?
-
Yes, only with it.
However, I'm not using a static build but that shouldn't change anything.
What platform are you on ?
@SGaist Installed the latest 5.9.2 snapshot, still getting the same errors...
I also tried building it into a new empty project rather than my production project, still a no-go.
Are you sure that you actually build it? Like in "register it as a QML type and see if it works".
-
I pasted your code in a main.cpp and instantiated an object from it and called the slot.
If you want more testing then provide a complete minimal buildable example.
One thing I saw with my build is that I still have the declarative sources in my git tree so it got built which might explain why I'm succeeding.
-
I pasted your code in a main.cpp and instantiated an object from it and called the slot.
If you want more testing then provide a complete minimal buildable example.
One thing I saw with my build is that I still have the declarative sources in my git tree so it got built which might explain why I'm succeeding.
-
I pasted your code in a main.cpp and instantiated an object from it and called the slot.
If you want more testing then provide a complete minimal buildable example.
One thing I saw with my build is that I still have the declarative sources in my git tree so it got built which might explain why I'm succeeding.
-
I'd try to check the resulting libraries to see which one contains the missing symbols.
-
OK, there has been some development, amazingly, I actually managed to get the first successful static Qt build since January. AND that code compiled successfully.
It is strange that it didn't compile with an identical configuration save for the static flag.
This actually works for me only in the context of development, which I do on windows. But it is an android app, and it still doesn't build on the stock Qt android build.
However, rather than getting unresolved reference errors, I get a
collect2.exe:-1: error: error: ld returned 1 exit statusCommenting out the cursorOp() function and it builds successfully.
It would seem that I'd have to also do a custom Qt build for android, something I haven't done and something I am certainly not looking forward to do, as every different platform has its new set of quirks and associated headaches.
-
-
Thanks for the link