[Qt-interest] Embedding QGraphicsView in a QGraphicsScene - no mousePressEvent
Ollie
saurero at gmail.com
Sun Nov 22 00:10:32 CET 2009
When embedding a QGraphicsView into a QGraphicsScene, the QGraphicsView does
not receive any mousePressEvents from the _right_ mouse button.
mouseMoveEvents and mouseReleaseEvents are received correctly from all mouse
buttons. This behaviour is observed when the windowFlag is set to something
different than Qt:Widget, for instance when set to Qt:Dialog.
Bellow you can find a minimal example, illustrating the problem.
I'm running Windows XP 64 bit together with Qt 4.5.3
Any help is greatly received!
Ollie
class View:
public QGraphicsView
{
public:
View()
{
setWindowFlags(Qt::Dialog);
}
~View(){}
protected:
void mouseMoveEvent(QMouseEvent *me)
{
if (me->buttons() == Qt::LeftButton){
cout << "View::mouseMoveEvent -> LeftButton" << endl;
}else if (me->buttons() == Qt::RightButton){
cout << "View::mouseMoveEvent -> RightButton" << endl;
}
}
void mousePressEvent(QMouseEvent *me)
{
if (me->buttons() == Qt::LeftButton){
cout << "View::mousePressEvent -> LeftButton" << endl;
}else if (me->buttons() == Qt::RightButton){
cout << "View::mousePressEvent -> RightButton" <<
endl;
}
}
void mouseReleaseEvent(QMouseEvent *me )
{
if (me->button() == Qt::LeftButton){
cout << "View::mouseReleaseEvent -> LeftButton" << endl;
}else if (me->button() == Qt::RightButton){
cout << "View::mouseReleaseEvent -> RightButton" <<
endl;
}
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QGraphicsView view1;
View view2;
view1.setScene(new QGraphicsScene());
view2.setScene(new QGraphicsScene());
view1.scene()->addWidget(&view2);
view1.resize(640, 480);
view1.show();
return app.exec();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091122/0149c8a0/attachment.html
More information about the Qt-interest-old
mailing list