Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Using a Qt private class in my cmake project
Forum Updated to NodeBB v4.3 + New Features

Using a Qt private class in my cmake project

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 1.1k Views
  • 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.
  • M Offline
    M Offline
    maxwell31
    wrote on 3 Dec 2019, 16:04 last edited by
    #1

    I wanted to make my own TreeView for my QtQuick application. I do not want to use the QuickControls1 TreeView (due to limited styling possibilities), however, I would like to use its qquicktreemodeladaptor which is the model used by the quick controls 1 treeview. Basically, it flattens the tree into a list. The source and header files are under /Qt5.13.1/5.13.1/Src/qtquickcontrols/src/controls/Private/. As this is a private class, how can I use it in my project? I am using Cmake, do I need to add something to find_package or to the target_link_libraries?

    J 1 Reply Last reply 4 Dec 2019, 06:53
    0
    • M maxwell31
      3 Dec 2019, 16:04

      I wanted to make my own TreeView for my QtQuick application. I do not want to use the QuickControls1 TreeView (due to limited styling possibilities), however, I would like to use its qquicktreemodeladaptor which is the model used by the quick controls 1 treeview. Basically, it flattens the tree into a list. The source and header files are under /Qt5.13.1/5.13.1/Src/qtquickcontrols/src/controls/Private/. As this is a private class, how can I use it in my project? I am using Cmake, do I need to add something to find_package or to the target_link_libraries?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 4 Dec 2019, 06:53 last edited by
      #2

      @maxwell31 You're showing the path to Qt sources.
      The path in a build Qt setup is like Qt/5.13.0/gcc_64/include/QtQuickControls2/5.13.0/QtQuickControls2/private/
      So, you should be able to include QtQuickControls2/private/*
      https://doc.qt.io/qt-5/qtquickcontrols-index.html

      But I'm not sure whether you need to do anything in your CMake files (for qmake see https://forum.qt.io/topic/61967/add-qtgui-private-headers).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxwell31
        wrote on 5 Dec 2019, 09:52 last edited by maxwell31 12 May 2019, 09:57
        #3

        Hi,
        True, I had the Qt sources here, and just used it there, which should not make a difference, right? At least with using this path, it did not complain that it would not find the header file. The problem I get is that when I compile the source which is using it, I get

        undefined reference to `QQuickTreeModelAdaptor1::QQuickTreeModelAdaptor1(QObject*)
        

        So I guess it has to do with the librarys I link to? Are those private classes in their own .so/.dll file?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maxwell31
          wrote on 5 Dec 2019, 10:51 last edited by
          #4

          The file qquicktreemodeladaptor_p.h is not present in the bult Qt version, its only present in the source.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maxwell31
            wrote on 5 Dec 2019, 11:04 last edited by
            #5

            Alternatively it might be possible to use the TreeModelAdaptor, as is done in the QtQuick Controls 1 (see TreeView in /Qt/Qt5.13.1/5.13.1/gcc_64/qml/QtQuick/Controls/Private )

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maxwell31
              wrote on 6 Dec 2019, 12:42 last edited by
              #6

              So for my specific problem, using the TreeModelAdaptor which is in Quick.Controls.Private works

              1 Reply Last reply
              0

              1/6

              3 Dec 2019, 16:04

              • Login

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