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. moc files overwrites
Forum Updated to NodeBB v4.3 + New Features

moc files overwrites

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.1k Views 1 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.
  • S Offline
    S Offline
    sailor.steve
    wrote on last edited by
    #1

    Hi all,
    I encountered difficulties with build program.
    I have directory architecture like this:

    -Category                
    -project.pro
    --v1.0                         
    ----Manager.h
    ----Manager.cpp
    --v2.0                        
    ----Manager.h
    ----Manager.cpp
    --v3.0                         
    ----Manager.h
    ----Manager.cpp
    

    All this classes have a such structure:

    namespace Category
    {
       namespace Version_{N}
       {
          class Manager : public QObject
          ...
       }
    }
    

    but when I compile my program, moc files overwrites each other because are created in root dir next to pro file
    Is there any way to solve this problem?

    jsulmJ 1 Reply Last reply
    0
    • S sailor.steve

      Hi all,
      I encountered difficulties with build program.
      I have directory architecture like this:

      -Category                
      -project.pro
      --v1.0                         
      ----Manager.h
      ----Manager.cpp
      --v2.0                        
      ----Manager.h
      ----Manager.cpp
      --v3.0                         
      ----Manager.h
      ----Manager.cpp
      

      All this classes have a such structure:

      namespace Category
      {
         namespace Version_{N}
         {
            class Manager : public QObject
            ...
         }
      }
      

      but when I compile my program, moc files overwrites each other because are created in root dir next to pro file
      Is there any way to solve this problem?

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

      @sailor.steve To be honest this is a strange way to support several versions of source code. Why don't you simply use a source control system like Subversion or Git and use branches for different versions?

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

      S 1 Reply Last reply
      1
      • jsulmJ jsulm

        @sailor.steve To be honest this is a strange way to support several versions of source code. Why don't you simply use a source control system like Subversion or Git and use branches for different versions?

        S Offline
        S Offline
        sailor.steve
        wrote on last edited by
        #3

        @jsulm said in moc files overwrites:

        @sailor.steve To be honest this is a strange way to support several versions of source code. Why don't you simply use a source control system like Subversion or Git and use branches for different versions?

        it customer requirement, needs to supported various of versions databases in same server.
        earlier this server supported only one database version but customer requested that server supported older versions.

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

          Hi,

          What is so different about these versions that they require different classes with almost the same name ?

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

          S 1 Reply Last reply
          3
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            You should split the project into 3 subprojects using the subdirs template. Then create a .pro file for each version where you can use MOC_DIR to specify a different directory for moc files

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            5
            • SGaistS SGaist

              Hi,

              What is so different about these versions that they require different classes with almost the same name ?

              S Offline
              S Offline
              sailor.steve
              wrote on last edited by
              #6

              @SGaist said in moc files overwrites:

              Hi,

              What is so different about these versions that they require different classes with almost the same name ?

              These classes for work with database.
              From version to version a struct of database has been changing
              These classes contains sql queries, designed to concrete version of database
              Presently desktop clients connect to the server wich can work only with concrete version of database
              For each version of desktop program is running appropriate server.
              Customer requires support various of versions databases in same server.

              jsulmJ 1 Reply Last reply
              0
              • S sailor.steve

                @SGaist said in moc files overwrites:

                Hi,

                What is so different about these versions that they require different classes with almost the same name ?

                These classes for work with database.
                From version to version a struct of database has been changing
                These classes contains sql queries, designed to concrete version of database
                Presently desktop clients connect to the server wich can work only with concrete version of database
                For each version of desktop program is running appropriate server.
                Customer requires support various of versions databases in same server.

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

                @sailor.steve You could change names of all these classes so they reflect the db version they support (like DbInterface01) and then add a version independent class which decides which of these classes to use (based on version) and uses it. All these version dependant classes should have a common base class.

                class DbInterface {};
                class DbInterface01 : public DbInterface {};
                ...
                class DbInterface0N : public DbInterface {};
                
                class DbManager
                {
                public:
                    DbManager()
                    {
                        // Just example code
                        if (dbVersion == 1)
                            dbInterface = new DbInterface01();
                    }
                private:
                    DbInterface *dbInterface;
                };
                

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

                1 Reply Last reply
                4

                • Login

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