Results 1 to 6 of 6

Thread: Proper way to store personnal classes

  1. #1
    Join Date
    Apr 2015
    Posts
    7
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Question Proper way to store personnal classes

    Hello Qt Center !

    I am kind of new to Qt but I manage to program a nice application with lots of classes subclassing QGraphicalsItems' children.

    Now I want to use thoses classes in another project.
    I would prefer not having to copy/paste everything and start typing all those path into que ".pro" again.

    As a newbie, what would you recommend to store my classes to be reusable later ? (note that I might want to do some changes again on those classes, as my program keep evolving...)

    I have hear about libraries, so that i could have some dll's ?
    I also read that some people are using templates ?
    I was thinking about storing all my classes into a new Qt project, but then I am not really sure how to reuse it...

    Regards,
    Max

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 96 Times in 93 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Proper way to store personnal classes

    You can take some of your classes and make a library out of them. Qt Creator has some templates to help you do that. If you prefer to write the .pro file manually, see http://doc.qt.io/qt-5/qmake-common-p...ding-a-library.

    You can choose whether to make a static library, whose binary code will be included in each application binary using it, or a dynamic library (DLL), which will need to be deployed along the applications linked to it.

  3. The following user says thank you to yeye_olive for this useful post:

    maxilase (2nd April 2015)

  4. #3
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Proper way to store personnal classes

    It is also typical to store your source code in some type of source code control system, like git, svn, etc. Your shared code can then be checked out in other projects as a git (or svn) subproject. You can still make changes and commit/share those changes with other projects or you can keep checked out versions different between projects if you desire.

  5. The following user says thank you to jefftee for this useful post:

    maxilase (2nd April 2015)

  6. #4
    Join Date
    Apr 2015
    Posts
    7
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: Proper way to store personnal classes

    Thank you very much for your answers.

    I have been looking for a step by step procedure on "How to create a library out of my project" and then "how to use the created library in my new project".
    But I got to say that I am struggling a bit. I never created a library before and the tutorial I have been looking at are pretty complicated...

    I was thinking about including my project as a subproject in my new project. Is that having any chance to work ? I just want to carry on my application and adapt a few changes in my class storage for time to time.

  7. #5
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Proper way to store personnal classes

    If by project you mean Qt *.pro projects, then yes you can do this, but your top level project needs to be a Qt subdirs project. You would organize your projects like this:

    application (subdirs project)
    - subproject (Qt subproject that includes a .pro and builds your dynamic or static library, tools, etc)
    - src (Qt project that includes a .pro and builds your application, etc)

    You can even nest subdir projects if needed:

    application (subdirs project)
    - libraries (subdirs project)
    - library1 (Qt dynamic library project, etc)
    - library2 (Qt static library project, etc)
    - src (your app, etc)

    Hope that helps.

  8. The following user says thank you to jefftee for this useful post:

    maxilase (3rd April 2015)

  9. #6
    Join Date
    Apr 2015
    Posts
    7
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: Proper way to store personnal classes

    Exactly what I was looking for, thank you !

Similar Threads

  1. How to access Classes from another Classes
    By revellix in forum General Programming
    Replies: 1
    Last Post: 4th August 2011, 15:39
  2. Proper way to use qmake and moc?
    By mossen in forum Newbie
    Replies: 1
    Last Post: 6th May 2011, 02:52
  3. construction of classes within classes
    By mobucl in forum Newbie
    Replies: 8
    Last Post: 10th January 2011, 13:51
  4. proper use of QList?
    By jhowland in forum Qt Programming
    Replies: 3
    Last Post: 13th September 2010, 14:57
  5. Proper way to #include Qt?
    By pherthyl in forum Qt Programming
    Replies: 1
    Last Post: 11th August 2006, 02:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.