MyWidget
::MyWidget( QWidget *parent,
const char *name,
const QGLWidget* shareWidget
)
this->setAcceptDrops(true);
label
= new QLabel("prove",
this);
}
void MyWidget::startDrag() {
printf("start drag\n");
QDragObject *d = new QTextDrag (this->label->text(), this);
d->dragCopy();
//do NOT delete d
}
printf("start drag enter event\n");
event->accept(QTextDrag::canDecode(event) || QImageDrag::canDecode(event));
}
printf("start drop event\n");
if (QImageDrag::decode(event, image)) {
//insertImageAt(image, event->pos());
}
else if (QTextDrag::decode(event, text)) {
//insertTextAt(text, event->pos());
}
}
MyWidget::MyWidget( QWidget *parent, const char *name, const QGLWidget* shareWidget)
: QGLWidget ( parent, name, shareWidget) {
this->setAcceptDrops(true);
label = new QLabel("prove", this);
}
void MyWidget::startDrag() {
printf("start drag\n");
QDragObject *d = new QTextDrag (this->label->text(), this);
d->dragCopy();
//do NOT delete d
}
void MyWidget::dragEnterEvent(QDragEnterEvent* event) {
printf("start drag enter event\n");
event->accept(QTextDrag::canDecode(event) || QImageDrag::canDecode(event));
}
void MyWidget::dropEvent(QDropEvent* event) {
printf("start drop event\n");
QImage image;
QString text;
if (QImageDrag::decode(event, image)) {
//insertImageAt(image, event->pos());
}
else if (QTextDrag::decode(event, text)) {
//insertTextAt(text, event->pos());
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks