sincnarf
15th October 2007, 04:53
sorry guys for my noobness but i have another problem
Given this custom graphics view... Whenever I press a mouse button a messagebox should appear but it's not. But when I change the QGraphicsSceneMouseEvent into QMouseEvent, the message box appears. And that is weird.
My graphicsView by the way has a pre loaded image (so this means it already has a default graphicsscene)
#include <QtGui>
#include "iadfuqgraphicsview.h"
IADFUQGraphicsView::IADFUQGraphicsView(QGraphicsSc ene *scene, QWidget* parent) :
QGraphicsView(scene, parent) {
setAcceptDrops(true);
setAttribute(Qt::WA_InputMethodEnabled);
setBackgroundRole(QPalette::Base);
setDragMode(QGraphicsView::RubberBandDrag);
setInteractive(true);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
setBackgroundBrush(QPixmap(":/images/background.png"));
setAutoFillBackground(true);
#ifdef QT_OPENGL_SUPPORT
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
#endif
// QGraphicsPixmapItem *m_pixmapItem = new QGraphicsPixmapItem(QPixmap::fromImage(QImage(":/images/circle.png")), 0, scene);
}
IADFUQGraphicsView::IADFUQGraphicsView(QWidget* parent) :
QGraphicsView(parent) {
setAcceptDrops(true);
setAttribute(Qt::WA_InputMethodEnabled);
setBackgroundRole(QPalette::Base);
setDragMode(QGraphicsView::RubberBandDrag);
setInteractive(true);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
setBackgroundBrush(QPixmap(":/images/background.png"));
setAutoFillBackground(true);
#ifdef QT_OPENGL_SUPPORT
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
#endif
}
void IADFUQGraphicsView::mousePressEvent(QGraphicsScene MouseEvent *event) {
QMessageBox::information(this, tr("Problem"), tr("Why isn't this message box showing?"));
}
Given this custom graphics view... Whenever I press a mouse button a messagebox should appear but it's not. But when I change the QGraphicsSceneMouseEvent into QMouseEvent, the message box appears. And that is weird.
My graphicsView by the way has a pre loaded image (so this means it already has a default graphicsscene)
#include <QtGui>
#include "iadfuqgraphicsview.h"
IADFUQGraphicsView::IADFUQGraphicsView(QGraphicsSc ene *scene, QWidget* parent) :
QGraphicsView(scene, parent) {
setAcceptDrops(true);
setAttribute(Qt::WA_InputMethodEnabled);
setBackgroundRole(QPalette::Base);
setDragMode(QGraphicsView::RubberBandDrag);
setInteractive(true);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
setBackgroundBrush(QPixmap(":/images/background.png"));
setAutoFillBackground(true);
#ifdef QT_OPENGL_SUPPORT
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
#endif
// QGraphicsPixmapItem *m_pixmapItem = new QGraphicsPixmapItem(QPixmap::fromImage(QImage(":/images/circle.png")), 0, scene);
}
IADFUQGraphicsView::IADFUQGraphicsView(QWidget* parent) :
QGraphicsView(parent) {
setAcceptDrops(true);
setAttribute(Qt::WA_InputMethodEnabled);
setBackgroundRole(QPalette::Base);
setDragMode(QGraphicsView::RubberBandDrag);
setInteractive(true);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
setBackgroundBrush(QPixmap(":/images/background.png"));
setAutoFillBackground(true);
#ifdef QT_OPENGL_SUPPORT
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
#endif
}
void IADFUQGraphicsView::mousePressEvent(QGraphicsScene MouseEvent *event) {
QMessageBox::information(this, tr("Problem"), tr("Why isn't this message box showing?"));
}