babu198649
27th July 2008, 06:40
hi
In the following code ,the mousePressEvent is not executed.does this means that the events first goes to child widgets and then to parents.
#include <QtGui>
class Widget : public QMainWindow
{
public:
Widget()
{
QDirModel *model = new QDirModel;
QListView *list =new QListView(this);
list->setModel(model);
this->setCentralWidget(list);
}
protected:
void mousePressEvent(QMouseEvent *event)
{
qDebug()<<"press";
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
In the following code ,the mousePressEvent is not executed.does this means that the events first goes to child widgets and then to parents.
#include <QtGui>
class Widget : public QMainWindow
{
public:
Widget()
{
QDirModel *model = new QDirModel;
QListView *list =new QListView(this);
list->setModel(model);
this->setCentralWidget(list);
}
protected:
void mousePressEvent(QMouseEvent *event)
{
qDebug()<<"press";
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}