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? -
Did you mean Custom Widget ? Or describe what is “Cusrom Widget” !
-
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. -
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.
Thank you!!