You have control over that. Look at the Qt Fridge Magnets example and the Draggable Icons example. Don't get hung up in the excessive detail, just try to get the concepts about how drag and drop work.The flow layout seems to go into the right direction. But is it possible to drag and drop? And if the Label is dropped onto the search bar removed from the flow layout and re added if removed from the search bar?
It is probably important to understand that you are not dragging and dropping the QLabel itself, you are creating a QDrag instance that contains QMimeData that represents the item you are dragging. So if you are selecting a QLabel for the drag, your mime data will contain the QLabel's text (and you might add the pixmap to the QDrag if your label also has an icon). This QDrag instance and its data is what is passed in the drag / drop event.
There was a long thread here recently which talked about drag and drop in list widgets, and how moving vs copying was handled. In this case, two QStringListModel instances were used to contain the strings in each of the list widgets. Flags returned by the model told whether copying and / or moving could happen.
So if you decide you want to implement move semantics (dragging and dropping moves a label / string from one window to another), then you will have to also implement creating and destroying QLabel instances as part of that. When a label is dropped, you will have to destroy the old instance and create a new one.
Look at the thread I referred to. It might be easiest to represent your filter terms in a QStringListModel, because the model will automatically handle the drag and drop and will send signals as it changes. The rowsRemoved() signal tells you that a string has been removed, and the rowsInserted() signals tells you when a string was added (dropped). You can then update your QLabels or whatever you choose to display the strings.
Bookmarks