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. Using a Qt application as a library
Forum Update on Monday, May 27th 2025

Using a Qt application as a library

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

    I would like to develop a non-GUI C++ application that some functionality from a Qt application. Would it be possible to set up (for example) a CMake project that makes functions from a Qt application available in some other source code?

    Appreciate this is quite a vague question, and would be happy to be more specific about what I have in mind if anyone has any ideas!

    Regards,

    Ben

    1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #2

      I think you should make a dll.

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      1
      • Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @steadysupply so to understand, you want to create an application that would reuse functionality available already in a Qt application, right?
        Ideally, such Qt application should be written in a way that GUI is separated from backend, and in this case you need to create a shared library (or DLL in Windows)with the backend features so it can be used by other applications.
        If changes to source code of Qt application is not possible, how is such Qt application exposing the feature(s) you want to use? (i.e. provinding different command line arguments make the application do some things? or does the Qt application expose some REST API?)

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • S Offline
          S Offline
          steadysupply
          wrote on last edited by
          #4

          I'm on Linux, so yes a shared library is what I'll need to create.

          As far as I know, the Qt application I'm looking at doesn't offer a command line interface (or other programmable interface) for the features I'm interested in.

          My question was really how would I start to go about creating a shared library from a Qt project that is designed to build an executable and not a shared library? The particular project in question is TeXstudio. I already asked a similar question over there: https://github.com/texstudio-org/texstudio/issues/30

          I imagine it would be a question of porting the qmake config files to some other build system (I'll probably use CMake) ... is this something people do? Are there any resources out there discussing common fitfalls etc?

          Cheers,

          Ben

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi
            As i see, you biggest issue with using it as a LIB will be to spin the message pump if you plan
            on letting the DLL show any GUI.
            https://stackoverflow.com/questions/11054087/starting-qt-gui-from-dll-in-dllstart-function

            1 Reply Last reply
            0
            • S Offline
              S Offline
              steadysupply
              wrote on last edited by
              #6

              Thanks for your reply. I don't intend on having the shared library display any UI, I just want to use some features of a Qt application in the backend for a web site; in particular the LaTeX parsing and rendering capabilities of TeXstudio (which is a Qt application).

              I'd like to hear from anyone who has done something similar, or has experience in porting a Qmake project to a more generic build system ...

              Cheers,

              Ben

              1 Reply Last reply
              0
              • Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by
                #7

                @steadysupply I guess that your main concern here should not be regarding the build system (which should be phase 2) but how/if the TeXstudio application was/is prepared from the very beginning for some parts of it to be compiled/built as a module, i.e. shared library.
                From a quick look at its source code, it doesn't look so easy... In that case, another path could be to use just the source code itself for the part(s) you need. This approach could have the potential drawback of maintenance, although you may want to use the features of the version control tool (i.e.) to handle external submodules

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                2
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi
                  Ok but if the parsing code uses anything Qt, it might not like to be created with no QApplication object.

                  QMake is a make maker. So its already generic. As much as CMake. If you look in the build folder, you will see it creates
                  a normale MakeFile.

                  1 Reply Last reply
                  1

                  • Login

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