Thanks for your response. Unfortunately, still no luck. I thought making my own class would do the trick.
Here's a sample version of my code. For some reason, it still does not respond to Drop events. I am trying to drag an icon from my desktop onto my GraphicsView window.
Any help you can give me would be greatly appreciated!
Also, I have two questions:
1) What is the difference between QDropEvent and QGraphicsSceneDragDropEvent?
2) As I understand it, I only need to include Q_OBJECT if I want to use signals, is that correct?
(For some reason, when I uncomment Q_OBJECT in my code, I get a bunch of "undefined reference to `vtable for MyGraphicsView'" errors.)
#include <QtGui/QApplication>
#include <QMainWindow>
#include <QGraphicsView>
#include <QDropEvent>
{
//Q_OBJECT // Do I need Q_OBJECT?
public:
protected:
//void dropEvent(QGraphicsSceneDragDropEvent *event);
};
{
this->setScene(scene);
}
{
qDebug("here");
}
int main(int argc, char *argv[])
{
MyGraphicsView *view = new MyGraphicsView(scene);
view->setAcceptDrops(true);
window.setCentralWidget(view);
window.resize(640, 480);
window.setAcceptDrops(true);
window.show();
return app.exec();
}
#include <QtGui/QApplication>
#include <QMainWindow>
#include <QGraphicsView>
#include <QDropEvent>
class MyGraphicsView : public QGraphicsView
{
//Q_OBJECT // Do I need Q_OBJECT?
public:
MyGraphicsView(QGraphicsScene *scene);
protected:
//void dropEvent(QGraphicsSceneDragDropEvent *event);
void dropEvent(QDropEvent *event);
};
MyGraphicsView::MyGraphicsView(QGraphicsScene *scene)
{
this->setScene(scene);
}
void MyGraphicsView::dropEvent(QDropEvent *event)
{
qDebug("here");
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
QGraphicsScene *scene = new QGraphicsScene;
MyGraphicsView *view = new MyGraphicsView(scene);
view->setAcceptDrops(true);
window.setCentralWidget(view);
window.resize(640, 480);
window.setAcceptDrops(true);
window.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks