Hi,
I want to be able to do drag & drop on a QListWidget, so I chose to subclass it. To do so, in Designer I selected it and clicked "Promote to custom widget", I named the new class FileList. I also created filelist.h, which I post there :
#include <QtGui>
Q_OBJECT
public:
};
#include <QtGui>
class FileList : public QListWidget {
Q_OBJECT
public:
FileList (QWidget *parent = 0);
void dragEnterEvent (QDragEnterEvent *event);
void dropEvent (QDropEvent *event);
};
To copy to clipboard, switch view to plain text mode
I also created filelist.cpp, to implement drag & drop functions :
#include "filelist.h"
}
if(event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
}
qWarning(event->mimeData()->text().toAscii());
}
#include "filelist.h"
FileList::FileList (QWidget *parent) : QListWidget(parent) {
}
void FileList::dragEnterEvent (QDragEnterEvent *event) {
if(event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
}
void FileList::dropEvent (QDropEvent *event) {
qWarning(event->mimeData()->text().toAscii());
}
To copy to clipboard, switch view to plain text mode
The problem is, in Designer preview, or in the final binary, the list does not appear anymore... Any clue ?
Bookmarks