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. cmake and Qt private headers

cmake and Qt private headers

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 5.8k 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.
  • SeeLookS Offline
    SeeLookS Offline
    SeeLook
    wrote on last edited by SeeLook
    #1

    Hi

    I need to subclass QQuickFlickable which is placed in private headers,
    so I'm trying to add proper statements to CMakeLists.txt
    I found that qgammaray does it:
    https://github.com/KDAB/GammaRay/blob/master/CMakeLists.txt

    QQuickFlickable class is placed in:

    /usr/include/qt/QtQuick/5.7.1/QtQuick/private/qquickflickable_p.h
    

    So I'm adding:

    if(NOT "${Qt5Qml_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQml/")
        string(REPLACE "/QtCore" "/QtQml" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
        list(APPEND Qt5Qml_PRIVATE_INCLUDE_DIRS ${replaceme})
        list(REMOVE_DUPLICATES Qt5Qml_PRIVATE_INCLUDE_DIRS)
    endif()
    if(NOT "${Qt5Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/")
        string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
        list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${Qt5Qml_PRIVATE_INCLUDE_DIRS})
        list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${replaceme})
        list(REMOVE_DUPLICATES Qt5Quick_PRIVATE_INCLUDE_DIRS)
    endif()
    
    include_directories( ${Qt5Quick_INCLUDE_DIRS} )
    include_directories( ${Qt5Quick_PRIVATE_INCLUDE_DIRS} )
    

    and list of include directories of my CMakeLists.txt looks like:

    get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
    foreach(dir ${dirs})
      message(STATUS "dir='${dir}'")
    endforeach()
    
    -- dir='/usr/include/qt'
    -- dir='/usr/include/qt/QtQuick'
    -- dir='/usr/include/qt/QtQml'
    -- dir='/usr/include/qt/QtNetwork'
    -- dir='/usr/include/qt/QtCore'
    -- dir='/usr/lib/qt/mkspecs/linux-g++'
    -- dir='/usr/include/qt/QtGui'
    -- dir='/usr/include'
    -- dir='/usr/include/qt/QtNetwork/5.7.1'
    -- dir='/usr/include/qt/QtNetwork/5.7.1/QtNetwork'
    -- dir='/usr/include/qt/QtCore/5.7.1'
    -- dir='/usr/include/qt/QtCore/5.7.1/QtCore'
    -- dir='/usr/include/qt/QtGui/5.7.1'
    -- dir='/usr/include/qt/QtGui/5.7.1/QtGui'
    -- dir='/usr/include/qt/QtQml/5.7.1'
    -- dir='/usr/include/qt/QtQml/5.7.1/QtQml'
    -- dir='/usr/include/qt/QtQuick/5.7.1'
    -- dir='/usr/include/qt/QtQuick/5.7.1/QtQuick'
    

    But if I include:

    #include <private/qquickflickable_p.h>
    

    It can not find private/qquickflickable_p.h
    but when I include this way:

    #define P_QQUICKFLICKABLE(major,minor,patch)  <QtQuick/major.minor.patch/QtQuick/private/qquickflickable_p.h>
    #include P_QQUICKFLICKABLE(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH)
    

    It complains about missing private/qtquickglobal_p.h from qquickflickable_p.h
    which is also in the same directory.

    Please help how to manage it.

    1 Reply Last reply
    0
    • SeeLookS Offline
      SeeLookS Offline
      SeeLook
      wrote on last edited by
      #2

      I give up... with using private headers.
      I did above by wrapping my component with Flickable on QML side.

      Anyway, it would find many practical purposes if QtQuick c++ classes will be not private.

      mrjjM 1 Reply Last reply
      0
      • SeeLookS SeeLook

        I give up... with using private headers.
        I did above by wrapping my component with Flickable on QML side.

        Anyway, it would find many practical purposes if QtQuick c++ classes will be not private.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @SeeLook said in cmake and Qt private headers:

        Anyway, it would find many practical purposes if QtQuick c++ classes will be not private.

        Indeed but there is a good reason for it.
        binary compatible.
        https://community.kde.org/Policies/Binary_Compatibility_Examples

        :)

        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