Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to make "Cusrom Widget" being able to drag-drop in?
I want my "Cusrom Widget" to be a container, like "group box", "tool box", "tab widget". We can drag another control widget to these control widget. But my "Cusrom Widget" can't accept the drag-drop, i can't drag another control widget into my "Cusrom Widget" .
How to make "Cusrom Widget" supports drag-drop?
maxvanceffer last edited by
Did you mean Custom Widget ? Or describe what is “Cusrom Widget” !
Guest last edited by
there is a draggable iocns example that ships with Qt sdk, have you seen its code? that be what you seek?
danilocesar last edited by
Is your cusrom widget "able to receive drops":http://doc.qt.nokia.com/4.7/qwidget.html#acceptDrops-prop?
Maybe "this":http://doc.qt.nokia.com/4.7/dnd.html can help you as well.
I'm sorry for my English.
There is an example "qt\examples\designer\customwidgetplugin".
I mean this is “Custom Widget”
In QtCreator, at left is control widget, in middle is work space, at right is property. The left is divided into Layouts, Spacers, Buttons, Containers, Input Widgets, Display Widgets ...
I create a "Qt Custom Designer Widget" project. Build it. Then I can see my "Cusrom Widget" at the QtCreator's left side.
I can drag my “Cusrom Widget” into the middle workspace, just like drag a QPushButton into workspace.
After I drag my “Cusrom Widget”into the middle workspace, name it myWidget, i want to drag a QPushButton into myWidget.
But myWidget does not accept.
If I drag a QTabWidget into the workspace, name it myTab, i can drag a QPushButton into myTab.
I want to ask how to design a customwidgetplugin like QTabWidget that could accept other control widget.
Read English is easy, but hard to write.
goetz last edited by
You should implement
bool isContainer() const;
and have it return true for your widget plugin.
See "QDesignerCustomWidgetInterface":http://doc.qt.nokia.com/4.7/qdesignercustomwidgetinterface.html for details.
[quote author="Volker" date="1288799498"]You should implement @ bool isContainer() const; @ and have it return true for your widget plugin. See "QDesignerCustomWidgetInterface":http://doc.qt.nokia.com/4.7/qdesignercustomwidgetinterface.html for details.[/quote]
Yes. It's taking effect.