Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to manage subdirs examples (C/C++) ?
QtWS25 Last Chance

How to manage subdirs examples (C/C++) ?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
subprojectexamples
8 Posts 4 Posters 400 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.
  • T Offline
    T Offline
    tccc
    wrote on last edited by
    #1

    I am asking for a discussion / advises on the following :
    I have a working Qt Creator "subdir" project and like to add specific example (sub project ) into it .

    The example was build using 5.15.x and works fine as an interdependent ".pro" project.

    When added as "existing (sub) project" it fails since ONE of the classes used was introduced in 6.8.1.
    ( in fails to find required header file )
    Forward declarations do not solve the issue...

    In shorts - I have a working subproject - created in 5.15.2 - and have a conflict adding subproject with class introduced in 6.8.1.

    Would it help to post some code here ?

    JonBJ 1 Reply Last reply
    0
    • T tccc

      I am asking for a discussion / advises on the following :
      I have a working Qt Creator "subdir" project and like to add specific example (sub project ) into it .

      The example was build using 5.15.x and works fine as an interdependent ".pro" project.

      When added as "existing (sub) project" it fails since ONE of the classes used was introduced in 6.8.1.
      ( in fails to find required header file )
      Forward declarations do not solve the issue...

      In shorts - I have a working subproject - created in 5.15.2 - and have a conflict adding subproject with class introduced in 6.8.1.

      Would it help to post some code here ?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @tccc
      I don't know much about subprojects. But if you have a piece of code/subproject which requires Qt 6.x surely you would either have to upgrade the rest of your code/projects to same Qt 6.x or make the subproject work as Qt 5.15, which would include it not using any Qt6 specific classes, if that can even be done? You won't be able to mix different Qt versions in an overall project.

      1 Reply Last reply
      1
      • T Offline
        T Offline
        tccc
        wrote on last edited by
        #3

        Thanks for the prompt reply. Much appreciated.
        For unknown reason(s) , which is not that important to resolve for now, , I have received couple of dozens error messages basically confirming my suspicion. ( I could post at least the relevant part, if there is an interest.)
        Here is one issue with " subprojects releases not matching " - when I initially started the project I had a choice to "select all kits" .
        That would indicate that each sub project "make" COULD use different release.
        ( BTW - I have not found HOW to actually verify each sub project "make" )

        On the other hand - what is wrong with assumption that HIGHER release should INCLUDE / build on PREVIOUS releases.
        Again - these are just opinions / speculations....

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

          Hi,

          Except that it's not how it works.
          The usual idea behind a subproject based project is that you separate various aspects of your big project with it but not try to build each with different versions of Qt.

          Unless you are using classes/methods that have been obsoleted and possibly removed, yes you should be able to build a Qt 5 project with Qt 6 if you followed the deprecation notices and kept your code up to date.

          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
          1
          • T Offline
            T Offline
            tccc
            wrote on last edited by
            #5

            update
            I am unable to verify if the sub directories MUST be compiled using same "kit".
            I am using "mdi" example as main, executable, subproject. Its "version" is 15.5.2 and so is my sub project (btscanner)
            Its ONLY btscanner example is also in "examples 15.5.2 " and work fine as stand alone .pro.
            BUT - it uses class introduced in 6.8.0 ! Hence there must be a way to identify HOW .pro project build using 15.5.2 (!) manages to USE class introduced in 6.8.0.

            BTW
            the "btscanner" has this in device.h and

            #include <qbluetoothlocaldevice.h>

            cannot be found when the btscanner.pro is added as subproject

            I believe that is the missing link why the btscanner.pro is failing to compile when added to sub project.

            This is part of "device.h header :

            #include <qbluetoothlocaldevice.h>

            #include <QDialog>

            QT_FORWARD_DECLARE_CLASS(QBluetoothDeviceDiscoveryAgent)
            QT_FORWARD_DECLARE_CLASS(QBluetoothDeviceInfo)

            QT_USE_NAMESPACE

            There is no forward declaration for
            QBluetoothLocalDevice

            jsulmJ JonBJ 2 Replies Last reply
            0
            • T tccc

              update
              I am unable to verify if the sub directories MUST be compiled using same "kit".
              I am using "mdi" example as main, executable, subproject. Its "version" is 15.5.2 and so is my sub project (btscanner)
              Its ONLY btscanner example is also in "examples 15.5.2 " and work fine as stand alone .pro.
              BUT - it uses class introduced in 6.8.0 ! Hence there must be a way to identify HOW .pro project build using 15.5.2 (!) manages to USE class introduced in 6.8.0.

              BTW
              the "btscanner" has this in device.h and

              #include <qbluetoothlocaldevice.h>

              cannot be found when the btscanner.pro is added as subproject

              I believe that is the missing link why the btscanner.pro is failing to compile when added to sub project.

              This is part of "device.h header :

              #include <qbluetoothlocaldevice.h>

              #include <QDialog>

              QT_FORWARD_DECLARE_CLASS(QBluetoothDeviceDiscoveryAgent)
              QT_FORWARD_DECLARE_CLASS(QBluetoothDeviceInfo)

              QT_USE_NAMESPACE

              There is no forward declaration for
              QBluetoothLocalDevice

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @tccc said in How to manage subdirs examples (C/C++) ?:

              BUT - it uses class introduced in 6.8.0 !

              Which one?
              As already stated: you can't mix different Qt versions in same application.

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

              1 Reply Last reply
              2
              • T tccc

                update
                I am unable to verify if the sub directories MUST be compiled using same "kit".
                I am using "mdi" example as main, executable, subproject. Its "version" is 15.5.2 and so is my sub project (btscanner)
                Its ONLY btscanner example is also in "examples 15.5.2 " and work fine as stand alone .pro.
                BUT - it uses class introduced in 6.8.0 ! Hence there must be a way to identify HOW .pro project build using 15.5.2 (!) manages to USE class introduced in 6.8.0.

                BTW
                the "btscanner" has this in device.h and

                #include <qbluetoothlocaldevice.h>

                cannot be found when the btscanner.pro is added as subproject

                I believe that is the missing link why the btscanner.pro is failing to compile when added to sub project.

                This is part of "device.h header :

                #include <qbluetoothlocaldevice.h>

                #include <QDialog>

                QT_FORWARD_DECLARE_CLASS(QBluetoothDeviceDiscoveryAgent)
                QT_FORWARD_DECLARE_CLASS(QBluetoothDeviceInfo)

                QT_USE_NAMESPACE

                There is no forward declaration for
                QBluetoothLocalDevice

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @tccc said in How to manage subdirs examples (C/C++) ?:

                BUT - it uses class introduced in 6.8.0 ! Hence there must be a way to identify HOW .pro project build using 15.5.2 (!) manages to USE class introduced in 6.8.0.

                As I said earlier, you cannot mix Qt versions in one overall project.
                If you understand C++/linking you would know that forward declarations can address a compile time issue but would leave you with a link-time error at linking since there is a declaration but no definition for the class.
                As per previous you have two choices:

                • Rewrite the Qt6 sub-project code so that it compiles and links as Qt5. That would mean you will have to completely remove any class which does not exist in Qt 5. Get rid of any need for a Qt6-only class, write your own definition for that class using Qt5, or else if you need it and cannot write it you are stuck.
                • Port the rest of your project/sub-projects to Qt6. Hopefully not too hard. Then you can use your new Qt6 sub-project in it.
                1 Reply Last reply
                3
                • T Offline
                  T Offline
                  tccc
                  wrote on last edited by
                  #8

                  Would it be acceptable to re-post the "update" ?
                  Upon further research I have found than the failing project ( all in 5.15 ) is actually part of subdir project,
                  and my guess is that that is why it worlds by itself but fails when added as subdir.
                  The "bluetooth.pro" "main" suproject actually consist of two more sub protects.

                  All of them are still "only" in 5.15 - no Qt 6 at all

                  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