A couple of classes are available which are derived from
QtWidgets.QLabel and provide specialized functionality.
Class implementing a label that accepts attributes that have been dragged from the Attributes tab.
When data of required formats is provided in the MIME data of the dragged object, an instance of this class emits one or two of the following Qt signals, to which slots can be connected using standard Qt code:
The above signals are only emitted when data of the following MIME data formats has been provided in the dragged object:
attribute/attr– Python code that can be executed to obtain an object that represents the dragged attribute
attribute/name– the name of the dragged attribute
In addition to the above formats, the following formats are also supported:
attribute/hints– a string representation of widget hints that were used for the widget from which the drag was started
attribute/scenegraphpath– the path of a scene graph location that contained the dragged attribute
Initializes an instance of the class.
The text of the label is hard-coded to Drop Attributes Here, the label is configured to accept drops, and its alignment is set to horizontally and vertically center the text inside of the label’s bounds.
Parameters: parent (
None) – The parent widget to own the new instance. Passed verbatim to the base class initializer.
Event handler for widget drag enter events which are passed in the
eventparameter. Is called when a drag is in progress and the pointer enters the widget.
If the event is ignored, the widget won’t receive any drag move events.
The implementation in this class accepts the given event if the required MIME data is provided.
Parameters: event (
QtGui.QDragEnterEvent) – The object that describes the event.
Event handler for widget drop events which are passed in the
eventparameter. Is called when the drag is dropped on the widget.
The implementation in this class checks if the required MIME data is provided in the given
event, and if so, evaluates the Python code given in the
attribute/attrformat to obtain the dragged attribute, as well as any widget hints that may be provided in the
attribute/hintsformat, and emits the
'attrDropped'signal with the dragged attribute, its name as taken from data of the
attribute/nameformat, and the decoded hints dictionary.
If data of the
attribute/scenegraphpathformat is provided as well, the function emits the
'attrDroppedWithScenegraphPath'signal with the dragged attribute, the attribute name, widget hints, and the path of the scene graph location that contained the dragged attribute.
Parameters: event (
QtGui.QDropEvent) – The object that describes the event.