How can I make a Qt Creator project that includes both a Qt plug-in and a demo application that uses it when run?
-
I'm working on a Qt Creator project that has two targets: a Qt plug-in, and a demo application that uses the Qt plug-in. I have it set up so that there's an overarching Qt subdirs project that includes both of the plug-in and application project, with the plug-in project being a dependency of the app project.
Both the app and plugin work as intended, and if I copy the built Qt plug-in to the global Qt plug-in directory, or I configure the "Run Settings" of the Qt Creator project so that it sets the
QT_PLUGIN_PATH
environment variable to the directory containing the plug-in, then the demo app finds it and uses it as intended.However, being that this project is meant to be an open source demo, I want people to be able to download it and run the demo app without needed to go through any additional steps to see the Qt plug-in working. All they should need to do is run the demo app from within Qt Creator.
Is there a way to do that? So far I haven't found any settings I can put in my .pro file that tells the demo app to add the build directory of the plug-in project to its plug-in search paths.
-
Hi,
Are you using the SUBDIRS template ?
If so, you can use the
OUT_PWD
variable to set where the plugin should be put upon build. With it you can put the plugin in the folder you want in the application project build folder. -
@SGaist said in How can I make a Qt Creator project that includes both a Qt plug-in and a demo application that uses it when run?:
Hi,
Are you using the SUBDIRS template ?
If so, you can use the
OUT_PWD
variable to set where the plugin should be put upon build. With it you can put the plugin in the folder you want in the application project build folder.Yes, I'm using a subdirs project that contains the Qt plugin and app projects.
However, my goal is to set up the .pro files used in these projects so that, when other users download the project, they can simply build and run the demo app from within Qt Creator and have the app find and load the Qt plug-in automatically, assuming that's possible. I can't do that by changing any build or run settings in Qt Creator as those are specific to a single system and aren't meant to be distributed.
-
@Guy-Gizmo that's exactly what my suggestion is about. It's independent of the fact to you use Qt Creator or build the project from the command line.
-
@SGaist said in How can I make a Qt Creator project that includes both a Qt plug-in and a demo application that uses it when run?:
@Guy-Gizmo that's exactly what my suggestion is about. It's independent of the fact to you use Qt Creator or build the project from the command line.
Can you go into more detail about how to do that? I don't know how to modify a .pro file so that the Qt plug-in gets built in or copied to the right place.
Furthermore, this project is primarily going to be built on macOS (though it may be run on Windows too), so I need to make sure it works in that case. I think that means the plugin needs to be copied into the correct place inside the demo app's application bundle, correct?
-
Something along the line of:
DESTDIR = $$OUT_PWD/../app_project/plugins/myplugins
Where app_project is the folder where your application is built and myplugins is the sub folder where you load your plugin from.