Qt-interest Archive, May 2008
Drag 'n Drop into a QGraphicsView
Message 1 in thread
Hi,
Any reason why a QGraphicsView won't accept drops _after_ one has set a scene
for that particular view? Before I set a scene to that view it accepts drops
just fine, but afterwards it's a no-go. Any ideas?
This guy's second question seems to be related:
http://lists.trolltech.com/qt4-preview-feedback/2006-09/thread00081-0.html
Any help is appreciated.
--
[ signature omitted ]
Message 2 in thread
Christopher Rasch-Olsen Raa wrote:
> Hi,
> Any reason why a QGraphicsView won't accept drops _after_ one has set a
> scene for that particular view? Before I set a scene to that view it
> accepts drops just fine, but afterwards it's a no-go. Any ideas?
> This guy's second question seems to be related:
> http://lists.trolltech.com/qt4-preview-feedback/2006-09/thread00081-0.html
> Any help is appreciated.
Hi, Christopher. Could you please send some code that shows what you mean?
QGraphicsView is built to forward DnD to the scene if one is set. If the
scene doesn't accept the events, though, they should propagate to the view.
--
[ signature omitted ]
Message 3 in thread
På Fredag 02 mai 2008 , 08:18:32 skrev Andreas Aardal Hanssen:
> Christopher Rasch-Olsen Raa wrote:
> > Hi,
> > Any reason why a QGraphicsView won't accept drops _after_ one has set a
> > scene for that particular view? Before I set a scene to that view it
> > accepts drops just fine, but afterwards it's a no-go. Any ideas?
> > This guy's second question seems to be related:
> > http://lists.trolltech.com/qt4-preview-feedback/2006-09/thread00081-0.htm
> >l Any help is appreciated.
>
> Hi, Christopher. Could you please send some code that shows what you mean?
> QGraphicsView is built to forward DnD to the scene if one is set. If the
> scene doesn't accept the events, though, they should propagate to the view.
Hi again,
Yeah, I figure it is built to forward DnD-events and I guess I'm doing
something wrong here, though I can't see what that is.
Here is an example showing what I mean:
#include <QtGui>
class MyView : public QGraphicsView {
public:
MyView(QWidget *parent = 0);
protected:
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
};
MyView::MyView(QWidget *parent) : QGraphicsView(parent) {
setAcceptDrops(true);
// Comment the line below, and drop starts working
setScene(new QGraphicsScene(this));
}
void MyView::dragEnterEvent(QDragEnterEvent *event) {
event->accept();
qDebug() << "Enter";
}
void MyView::dropEvent(QDropEvent *event) {
qDebug() << event->mimeData()->formats();
}
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QMainWindow mainwindow;
MyView view;
mainwindow.setCentralWidget(&view);
mainwindow.show();
return app.exec();
}
I've been staring myself blind, so any help is appreciated.
Best,
Christopher
--
[ signature omitted ]
Message 4 in thread
På Søndag 04 mai 2008 , 13:44:17 skrev Christopher Rasch-Olsen Raa:
[snip]
>
> I've been staring myself blind, so any help is appreciated.
>
> Best,
> Christopher
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
Ok, so now I'm just about ready to shoot myself with bent spoons. Implementing
QGrpahicsView::dragMoveEvent() solved it.
Yet another PEBKAC.
--
[ signature omitted ]