How to make "Cusrom Widget" being able to drag-drop in?
-
wrote on 3 Nov 2010, 07:51 last edited by
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? -
wrote on 3 Nov 2010, 08:48 last edited by
Did you mean Custom Widget ? Or describe what is “Cusrom Widget” !
-
wrote on 3 Nov 2010, 09:11 last edited by
there is a draggable iocns example that ships with Qt sdk, have you seen its code? that be what you seek?
-
wrote on 3 Nov 2010, 10:48 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.
-
wrote on 3 Nov 2010, 13:22 last edited by
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. -
wrote on 3 Nov 2010, 15:51 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.
-
wrote on 4 Nov 2010, 00:37 last edited by
[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!!
1/7