QtCreator - Custom widget plugin and mouse click event
-
Hi all
I'm developing a custom widget plugin for QtCreator. My widget is container type, very similar to QTabWidget, this mean accept pages and so on. I developed the plugin and all is working well. The only "feature" I can not add yet is the mouse click inside the QtDesigner window panel. If you add the QTabWidget inside the QtDesigner target window you can move between QTabWidget pages by directly click over the tab of the control. I would to obtain the same result but it seem QtCreator filter all mouse down events and doesn't allow to reach the widget managed by the plugin. I checked all examples but still not found a way, someone can suggest a a solution?
Thank you -
Unfortunately there's no interface to do what you want. Designer plugins are quite limited in what they can do.
Note that all they do is provide an xml description of your widget's properties in .ui file and, as such, can't do anything that uic doesn't understand.
A plugin is pretty much a list of properties of very limited QVariant types subset.
The only difference of a container plugin is that it allows designer to set a layout (a single one) and add child widgets to it. That is pretty useless for a tabwidget-like plugin, since it would need a layout for each tab. -
Hi
Thank you for your reply. However why QTabWidget "component" work in different way and allow to manage click events? I guess the reply is this component is not managed by a plugin but is in some way part of QtCreator main code and have a different possibilities, is this correct? I tried to get the QtDesigner sources but still didn't fine the code managing this windget... -
If someone is interested the solution to this problem can be found here:
http://falsinsoft.blogspot.com/2016/02/qt-designer-develop-custom-widget.html
-
This is an implementation detail of a private API. You shouldn't be using this in your plugins. It's not documented and it may change in future versions unannounced.
Besides, as I mentioned earlier, getting mouse events is not enough to implement a tabwidget-like plugin. Modifications of the .ui format and uic tool would be needed. -
After added this prefix to object name as explained in the article I was able to develop a plugin workig in the exacly same way of QTabWidget without any specific change in the widget code. By the way, just for try to clarify to myself, I tried to made some search and I found the same object name prefix is used in the official Qt example here:
http://doc.qt.io/qt-5/qtdesigner-containerextension-example.html
However there is no info regarding this prefix but if this trick is reported in an example of Qt package I guess it will be keep in the future. In case of change I'll modify my plugin too based to the new way...