Custom plugin with CMake
-
Hello,
I have created several widgets for a library that I developed that are the different GUIs for the different parts of my library. My library is compiled using cmake and using it I can compile all the widgets as well as a main window that uses them. My next step is to try and make these widgets available in the QtCreator or designer. However, I have found very few information on how to do this using cmake instead of qmake. I have created this small project based on the analog clock examples that is widely available. There I create both a widget and a plugin interface (that inherits from QDesignerCustomWidgetInterface). Everything compiles fine and I can install the files as well (sudo make install). However, when I restart qtcreator the plugin does not appear. I have several questions that sum up to: Can somebody tell me what am I doing wrong?
- Is it possible to create a plugin with qt4 that will be loaded to a qtcreator that was compiled using qt5?
- Where should I actually install the plugin(I am using Ubuntu)?
- Should I install something else a part from the plugin part? My guess is that the widget itself should be installed as well. Where? How can i provide a CMake to find it?
Thank you very much!
-
Ok, I think I have it. Please go here if you want to see how I did it. Feel free to criticize it as much as possible, this way I will be able to improve it. It only works in Qt4. The Qt5 branch in the git repository only compiles the stand alone libraries and the cmake part is not well resolved as for Qt4.
-
@apalomer said in Custom plugin with CMake:
Hi-
Is it possible to create a plugin with qt4 that will be loaded to a qtcreator that was compiled using qt5?
No, its a DLL/so file and must use the same version of Qt that Creator is build with AND compiler.
(visual studio 2015, in release mode , mingw is not supported out of the box) -
Where should I actually install the plugin?
C:/Qt/Qt5xxx/Tools/QtCreator/lib/qtcreator/plugins/
C:/Qt/Qt5xxx/Tools/QtCreator/bin/plugins/designer -
Should I install something else a part from the plugin part? My guess is that the widget itself should be installed as well.
The plugin normally include the widget code also. Only if widget uses external other dlls/so files , those should be included -
How can i provide a CMake to find it?
Sorry, i dont know cmake very well.
[edit: Fixed path SGaist]
-
-
@apalomer
Well its same in linux regarding placement.
so where u installed Qt + /Tools/QtCreator/bin/plugins/designer
You can do
locate Welcome.so to see
mine is in
/home/master/Qt5.7.1/Tools/QtCreator/bin/plugins/designer
but it depends on where you did in fact install it.In linux , you should use the same version of gcc as Creator was compiled with. ( there can be a bit more of version diff than in windows) But a Qt4 plugin in a Qt5 Creator is most likely asking too much.
Check in help->about Creator menu what version of gcc you need
-
UPDATE
Not enough coffee syndrom.
The path i shown is for Creator plugins.
You were actually asking for
xx/Tools/QtCreator/bin/plugins/designer -
Ok, I think I have it. Please go here if you want to see how I did it. Feel free to criticize it as much as possible, this way I will be able to improve it. It only works in Qt4. The Qt5 branch in the git repository only compiles the stand alone libraries and the cmake part is not well resolved as for Qt4.
-
Super and thx for sharing.
Very useful for people ever want to use cmake for plugins.
All docs uses qmake. -
@apalomer
Yeah and while qmake.exe is pretty nice as a tool,
i found the language pretty awkward and non intuitive but luckly
there are tons of online help.Btw did you get Creator to syntax highlight the cmakle.txt file as it does with .pro file?
-
@apalomer
when using .pro file, if you open it, in Creator,
it colors the keywords like it would in a .cpp/h file.
It can also autocomplete and guess like for class etc.With my brief encounters with cmake, it could not get it to do
any of these things even it does understand its a project file but its
shown as a text file with no coloring and no code completion possible.I just wondered if i had missed something to enable to make Creator provide such features
to cmake projects also. -
I do not know how I did it, but the CMake part works. CMake functions such as find_package, add_dependencies would be highlighted and you can also get the tooltip information as well as autocomplete. I do not know if it actually allows for autocomplete of anything that is not CMake built in (such as some macro that you might develop)