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. [Solved] QXmlNodeModelIndex::stringValue link failure under Linux
Forum Updated to NodeBB v4.3 + New Features

[Solved] QXmlNodeModelIndex::stringValue link failure under Linux

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 2.8k Views 3 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.
  • U Offline
    U Offline
    ukoehler
    wrote on last edited by
    #1

    Hi there,

    I have a Qt 5.2.1 project that I compile with Gcc under Windows and Linux. Everything works for Windows, however, the executable won't link under Linux. In both cases I will get the following warning:

    inline function 'QString QXmlNodeModelIndex::stringValue() const' used but never defined [enabled by default]

    This links and works for Windows, but for Linux I get:

    undefined reference to 'QXmlNodeModelIndex::stringValue() const'

    The Cmake projects requires Qt5XmlPatterns with FIND_PACKAGE(Qt5XmlPatterns REQUIRED)
    and links the lib with QT5_USE_MODULES(${TARGET} Core Sql Network Xml XmlPatterns)

    I wrote a sample application using qmake to reproduce the problem:
    main.pro:
    @
    CONFIG += qt debug
    SOURCES += main.cpp
    QT += xmlpatterns
    @

    main.cpp:
    @
    #include <QCoreApplication>
    #include <QBuffer>
    #include <QXmlQuery>
    #include <QXmlResultItems>
    #include <QXmlItem>
    #include <iostream>

    int main(int argc, char **argv)
    {
    QCoreApplication app( argc, argv );
    QBuffer buffer;
    buffer.open(QIODevice::ReadWrite);
    buffer.write("<?xml version="1.0"?>");
    buffer.write("<element><sub>a</sub><sub/></element>");
    buffer.seek(0);
    QXmlQuery query;
    query.setFocus( &buffer );
    query.setQuery("//element/sub");
    QXmlResultItems results;
    query.evaluateTo( &results );
    QXmlItem item = results.next();
    while( !item.isNull() ) {
    if( item.isNode() ) {
    std::cout << "Found node " << item.toNodeModelIndex().stringValue().toStdString() << std::endl;
    }
    item = results.next();
    }
    buffer.close();
    }
    @

    Works under Windows:
    @
    $./main.exe
    Found node a
    Found node
    @

    Fails to link under Linux:
    @
    g++ -Wl,-rpath,/opt/Qt/5.2.1/gcc_64 -Wl,-rpath,/opt/Qt/5.2.1/gcc_64/lib -o main main.o -L/opt/Qt/5.2.1/gcc_64/lib -lQt5XmlPatterns -lQt5Network -lQt5Gui -lQt5Core -lGL -lpthread
    main.o: In function main': /home/ukoehler/devel/QtProblems/ModelNodeIndex_stringValue/main.cpp:24: undefined reference to QXmlNodeModelIndex::stringValue() const'
    collect2: error: ld returned 1 exit status
    @

    Any help would be greatly appreciated.

    Uwe Köhler

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

      Hi and welcome to devnet,

      What surprises me is that it works on windows. The documentation from QXmlNodeModelIndex doesn't mention any stringValue() function

      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
      • U Offline
        U Offline
        ukoehler
        wrote on last edited by
        #3

        Many thanks for your reply. The member stringValue() is inherited from QAbstractXmlNodeModel. I nosed around the source code and couldn't find any implementation of the function (obviously didn't look long enough).

        Is this a bug? Should I commit a bug report?

        Cheers

        Uwe Köhler

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

          AFAIK, QXmlNodeModelIndex doesn't inherit from QAbstractXmlNodeModel. However, you can use it with stringValue from QAbstractXmlNodeModel.

          e.g.

          @
          QXmlNodeModelIndex index = item.item.toNodeModelIndex();
          qDebug() << model->stringValue(index);
          @

          So it's strange that it's working on windows.

          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
          • U Offline
            U Offline
            ukoehler
            wrote on last edited by
            #5

            Ah, the QXmlNodeModelIndex file just includes qabstractxmlnodemodel.h and there I can find the public member inline QString QXmlNodeModelIndex::stringValue() const. But you are absolutely correct, it is not derived from QAbstractXmlNodeModel.

            Well, Eclipse showed that the member exists, but didn't show the comment above that:
            @
            /* The members below are internal, not part of the public API, and

            • unsupported. Using them leads to undefined behavior. */
              @

            Many thanks for your help. Didn't see that without you pointing me in the right direction.

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

              You're welcome !

              I still find strange that you can actually use them on Windows and not on linux, there might be something fishy.

              If you want to know more about it, you can ask on the interest mailing list. You'll find Qt's developers/maintainers there (this forum is more user oriented)

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

              K 1 Reply Last reply
              0
              • SGaistS SGaist

                You're welcome !

                I still find strange that you can actually use them on Windows and not on linux, there might be something fishy.

                If you want to know more about it, you can ask on the interest mailing list. You'll find Qt's developers/maintainers there (this forum is more user oriented)

                K Offline
                K Offline
                kumararajas
                wrote on last edited by
                #7

                @SGaist Hi Sam,

                I get the similar problem while using stringValue(). Looks like it is not implemented.

                Is there anyway to overcome this?

                Thanks!

                --Kumar

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

                  Hi,

                  It's an internal function of QXmlNodeModelIndex and from the looks of it, unused and not implemented.

                  AFAICS, you should use the model stringValue method to get the data from the index.

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

                  K 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Hi,

                    It's an internal function of QXmlNodeModelIndex and from the looks of it, unused and not implemented.

                    AFAICS, you should use the model stringValue method to get the data from the index.

                    K Offline
                    K Offline
                    kumararajas
                    wrote on last edited by
                    #9

                    @SGaist Thanks for the clarification Sam..

                    --Kumar

                    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