PDA

View Full Version : disabling mouse event



elessaar
11th September 2008, 13:24
is it possible to disable mouse enter and leave events

jacek
11th September 2008, 20:51
You can use an event filter to filter them out.

elessaar
16th September 2008, 13:36
i tried that. i have my own label classes. and im drawing graphs on that labels.

when mouse enter and leave events happens on those labels, paint event still being called. but i want the paint event to be called only with my signal.

in constructor:
emi_label->installEventFilter(this);
gpr_label->installEventFilter(this);


bool mainWidget::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::Enter || event->type() == QEvent::Leave){
if(obj == this){
qDebug("warning: main event");
}
if(obj == emi_label){
qDebug("warning: emi event");
}
if(obj == gpr_label){
qDebug("warning: gpr event");
}
}
return false;
}

event catches are right as far as i can see. i see expected warnings on terminal


///////////////////////////////////////////////////////////////////////////////////////////////////////////
void gprLabel::update_gui(){

if(is_gpr_data_ready){
for(int i=101;i<=228;i++){
gpr_matrix[gpr_matrix_index][i-101] = rand()%256;
}
gpr_matrix_index++;
is_gpr_data_ready = 0;
}

if(gpr_matrix_index == vWIDTH ){
gpr_matrix_index = 0;
is_ready_to_draw = 1;
update();
}
}

as u see i want gpr_label to be updated only with my call. how can do that

SASA
16th September 2008, 14:11
Assistant:

if you want to filter the event out, i.e. stop it being handled further, return true;
bool mainWidget::eventFilter(QObject *obj, QEvent *event)
{

if(event->type() == QEvent::Enter || event->type() == QEvent::Leave)
{

if(obj == this)
{

qDebug("warning: main event");

}
if(obj == emi_label)
{

qDebug("warning: emi event");
return true;
}
if(obj == gpr_label)
{

qDebug("warning: gpr event");
return true;
}
}
return QMainWindow::eventFilter(obj, event);
}

elessaar
17th September 2008, 07:36
when i do that, my labels become invisiable. i dont see any of them.

also im getting error if i use QMainWindow::eventFilter(). "cannot call member function without object..."

aamer4yu
17th September 2008, 08:06
Is your mainwidget derived from QMainWindow ??
Also why do u want to call other eventfilter from ur filter ?
just return true or false

elessaar
17th September 2008, 09:42
i was referring to the code above my last post.

the important thing now is if i return true my labels become invisible.

aamer4yu
17th September 2008, 10:03
I guess I am missing something in understanding ur problem...
u want to paint only when ur signal is emitted, right ? You can hold a variable and update it on the signal emitted. Use this variable in paint event.
May be i am wrong in understanding..

can u tell me if i am getting ur prob right.. cud u please explain a bit more of what u actually wanna do ?