QCustomPlot Discussion and Comments

How to drag and drop item from QListWidget onto QCustomPlotReturn to overview

Hi

Main window contains the following:

Main window created using QtDesigner.

QWidget (the main window) contains a QTabWidget (with one tab) that contains QVBoxLayout called vLayout. Within vLayout, I have 2 QCustomPlot objects (one at index 0 of vLayout, one at index 1 of vLayout

QDialog pops-up when user clicks button within main window menu bar.

The creation of the following QDialog was made using code, I did not use QtDesigner.

QDialog contains the following:

QDialog called dialogTitles contains QListWidget called listWidgetTitles. Within listWidgetTitles, I have 3 items added using:

listWidgetTitles->addItem(“A”); // “A” is at index 0 of listWidgetTitles
listWidgetTitles->addItem(“B”); // “B” is at index 1 of listWidgetTitles
listWidgetTitles->addItem(“C”);	 // “C” is at index 2 of listWidgetTitles

GOAL: How can I drag an item from listWidgetTitles that is inside dialogTitles, then hover over a QCustomPlot object located in my main window and then proceed to drop that item? After dropping the item the QCustomPlot must somehow change its tilte to whatever string was dropped onto it. Any ideas as to how I can implement this?

Have a look at how Drag&Drop can be done with Qt in general:
http://doc.qt.io/qt-5/dnd.html
QCustomPlot is not special, it's just a QWidget. So you can subclass it and set its setAcceptDrops(true);, and reimplement the according virtual methods dragEnterEvent and dropEvent.

Thank you, I will try that.