PDA

View Full Version : Qt4.4 ignores event->ignore()



babu198649
10th January 2008, 10:30
hi
this question is related to preview release of Qt4.4

in Qt4.4 the event->ignore does not work in QGraphicsView .

heres the code


#include <QtGui>

class gv : public QGraphicsView
{
public:
gv(QWidget *parent = 0);

protected:
void mousePressEvent(QMouseEvent * event);

private:
QGraphicsScene *scene;
QTreeView *tree;
QDirModel *model;
};

gv::gv(QWidget *parent) : QGraphicsView(parent)
{
scene = new QGraphicsScene;
this->setScene(scene);

tree = new QTreeView;
scene->addWidget(tree);

model = new QDirModel;
tree->setModel(model);
tree->show();
}

void gv::mousePressEvent(QMouseEvent * event)
{
event->ignore();
}

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
gv w;
w.show();
return a.exec();
}


in the above program if the mousePressEvent is not implemented then the treeview expands on singleclick.

but if the mousePressEvent is reimplemented and even when the events are ignored inside the mousePressEvent function as in the above program the widgets added to the scene does not receive the events.

this problem occurs with mouseDoubleClickEvent and wheelEvent also

i have installed eventFilter to the viewport and ignored the events(return false) even then the events are not received by the widgets that are added to the scene.

how to ignore the events .

Thanks in advance