Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. undefined reference to `QQuickTextControl::textCursor() const'
Qt 6.11 is out! See what's new in the release blog

undefined reference to `QQuickTextControl::textCursor() const'

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 2 Posters 5.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by SGaist
    #2

    Hi,

    From a quick look at Qt's sources, that class comes from the QtDeclarative module.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    I 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      From a quick look at Qt's sources, that class comes from the QtDeclarative module.

      I Offline
      I Offline
      iter
      wrote on last edited by
      #3

      @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 QDeclarativeTextControl instead?

      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 control functions:

      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?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        What version of Qt are you using ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        I 1 Reply Last reply
        0
        • SGaistS SGaist

          What version of Qt are you using ?

          I Offline
          I Offline
          iter
          wrote on last edited by
          #5

          @SGaist Latest 5.9.1

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            I've successfully built it with 5.9.2.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            I 1 Reply Last reply
            0
            • SGaistS SGaist

              I've successfully built it with 5.9.2.

              I Offline
              I Offline
              iter
              wrote on last edited by
              #7

              @SGaist Did you have to do anything particular?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                Nothing special, the only difference I can see is that it's a self-built Qt but that shouldn't matter.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                I 1 Reply Last reply
                0
                • SGaistS SGaist

                  Nothing special, the only difference I can see is that it's a self-built Qt but that shouldn't matter.

                  I Offline
                  I Offline
                  iter
                  wrote on last edited by
                  #9

                  @SGaist Only using quick-private?

                  It has been a while since I was able to get a successful Qt build, but I only do static custom builds, and that hasn't work since 5.8 and the "build system (so called) improvements"...

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Yes, only with it.

                    However, I'm not using a static build but that shouldn't change anything.

                    What platform are you on ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    I 2 Replies Last reply
                    0
                    • SGaistS SGaist

                      Yes, only with it.

                      However, I'm not using a static build but that shouldn't change anything.

                      What platform are you on ?

                      I Offline
                      I Offline
                      iter
                      wrote on last edited by
                      #11

                      @SGaist It is the "stock" Qt pre-build, on windows 7 with mingw, dynamic linking and so on.

                      This is certainly odd.

                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Yes, only with it.

                        However, I'm not using a static build but that shouldn't change anything.

                        What platform are you on ?

                        I Offline
                        I Offline
                        iter
                        wrote on last edited by
                        #12

                        @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".

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          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.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          I 2 Replies Last reply
                          0
                          • SGaistS SGaist

                            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 Offline
                            I Offline
                            iter
                            wrote on last edited by
                            #14

                            @SGaist Well, I'll give a barebone build a try and see if it makes a difference.

                            However, it says that:

                            All classes that were previously in the QtDeclarative module have been moved into the Qt QML and Qt Quick modules
                            

                            So maybe it is a bug of some sort?

                            1 Reply Last reply
                            0
                            • SGaistS SGaist

                              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 Offline
                              I Offline
                              iter
                              wrote on last edited by
                              #15

                              @SGaist I built Qt from source, declarative was definitely built.

                              Still the same errors.

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                I'd try to check the resulting libraries to see which one contains the missing symbols.

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0
                                • I Offline
                                  I Offline
                                  iter
                                  wrote on last edited by
                                  #17

                                  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 status

                                  Commenting 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.

                                  1 Reply Last reply
                                  0
                                  • I Offline
                                    I Offline
                                    iter
                                    wrote on last edited by
                                    #18

                                    https://bugreports.qt.io/browse/QTBUG-62948

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      Thanks for the link

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved