PDA

View Full Version : focus events of widget children



daemonna
25th January 2011, 12:58
hi, i got common widget with textarea and calendar... currently i listen for mouse over regarding whole widget (not it's children), showing calendar when over widget, hiding when mouse it's out of widget..


#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
ui->calendarWidget->hide();
}

Widget::~Widget()
{
delete ui;
}

void Widget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}

void Widget::enterEvent(QEvent *e)
{
ui->calendarWidget->show();
}

void Widget::leaveEvent(QEvent *e)
{
ui->calendarWidget->hide();
}


but i have no clue how to listen for mouseevent if i want same functionality with focus only on textedit... that means, i wanna show calendar only when mouse is over textedit (and textedit only)...

any help appreciated.. thanks

high_flyer
25th January 2011, 20:15
Have a look at QObject::installEventFilter().