You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, December 21st 2005, 3:14pm

mouseMoveEvent & QFileDialog

Hi,
wheen I call a QFileDialog and I saw that (after when I choose a file and
close dialog) the mouseMoveEvent is called!!!How can avoid this call?
Thanks
Regards,

hatulflezet

Professional

Posts: 1,301

Location: Munich Germany

Occupation: Programmer

  • Send private message

2

Thursday, December 22nd 2005, 10:37am

I guess i was not the only one who didn't understand what you mean (no one asnwered till now).
Could you explain a bit more?
Click here! I dare ya'!! :]
Project Archimedes
----------------------------------------------------------
"Don't panic, and thanks for all the fish!"

3

Thursday, December 22nd 2005, 2:41pm

mouseMoveEvent & QFileDialog

Hi,
I have a button that call "QFileDialog::getOpenFileName". I choose a file
from list and dialog closed. Below there is a function:

Source code

1
2
3
4
mywidget::mouseMoveEvent() {
     cout << "mouseMove"
     .........
}

I see that this function is automatically called after I closed QfileDialog and
the code inside the mouseMoveEvent() is execute.
Do you understand? It's a strange thing....
Regards,

hatulflezet

Professional

Posts: 1,301

Location: Munich Germany

Occupation: Programmer

  • Send private message

4

Thursday, December 22nd 2005, 3:01pm

If I understand right, you are calling QFileDialog::getOpenFileName in mywidget.
If this is so, then mouseMoveEvent() has nothing to do with the fact you opened/closed the dialog, other then when you closed the dialog, the mouse got back to mywidget, which then generated a mouseMoveEvent.
If you then contenue to move the mouse over mywidget mouseMoveEvent() will contenue to be called and actually,also before you call QFileDialog::getOpenFileName.
Click here! I dare ya'!! :]
Project Archimedes
----------------------------------------------------------
"Don't panic, and thanks for all the fish!"

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

5

Thursday, December 22nd 2005, 3:20pm

It is probably because when you clicked on the button, you also moved your mouse, which generated the move event which was handled after the "clicked()" signal emitted from within mousePressEvent handler. The clicked() signal is probably connected to a slot which opens a modal dialog causing events from parent window to not being handled during life of the modal dialog. When the dialog is closed, the flow returns to the main event queue, causing the next event (which is the move event) to be handled. Of course this is theory :) You can try applying an event filter to the button and handling mouseMove there (which will prevent it from being forwarded to the parent of the button).

6

Thursday, December 22nd 2005, 4:50pm

mouseMoveEvent & QFileDialog

QFileDialog::getOpenFileName is called form mainform.ui.h.
I know what happen but I don't understand what I can do!
( I have some problem with English).....Can you speak a bit more simply?
Thanks.
Regards,

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

7

Thursday, December 22nd 2005, 4:56pm

RE: mouseMoveEvent & QFileDialog

As I said -- apply an event filter on the push button and filter its mouseMoveEvents there (note that this way you won't be able to receive any move events that occur over the button, unless you do it in a smart way).

8

Thursday, December 22nd 2005, 8:42pm

mouseMoveEvent & QFileDialog

Ok,
but I have a button of MainForm that call a function MainForm::load().
Within this function I call QFiledialog::open....But I think that I must
install an eventFilter on QFileDialog?? But don't work (eventFilter is not
called). If I install a filter on button that calls load(), the button is blocked.
I see that when I open fileDialog, mouseMovevent is called
only when I choose a file with double click on it and not when I click on
file and press open button of OpenDialog.
Regards,

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

9

Friday, December 23rd 2005, 12:06am

RE: mouseMoveEvent & QFileDialog

Quoted

Originally posted by mickey
Ok,
but I have a button of MainForm that call a function MainForm::load().
Within this function I call QFiledialog::open....But I think that I must
install an eventFilter on QFileDialog??


No. Install an event filter on the button so that its mouse move event is not forwarded to its parent.

Quoted

But don't work (eventFilter is not
called).

It depends what you did.

Quoted

If I install a filter on button that calls load(), the button is blocked.


Do you actually handle some of the events there and pass the rest?

Quoted

I see that when I open fileDialog, mouseMovevent is called
only when I choose a file with double click on it and not when I click on
file and press open button of OpenDialog.

So take a debugger and see why it happens.

10

Friday, December 23rd 2005, 12:47am

mouseMoveEvent & QFileDialog

I insert in mainForm::init()

Source code

1
2
//mainForm.ui.h
this->load->installEventFilter(this->myWidget1);

and

Source code

1
2
3
4
5
6
7
8
9
10
//MyWidget.cpp
bool MyWidget::eventFilter(QObject* obj, QEvent* e) {
	if ( e->type() == QEvent::MouseMove) {
		  cout << "mo";
		  return  true;
	  } 
	else {
		cout << "false\n";
		return false;
	}

So eventFilter is called when I pass with mouse on button "load" and
return false.
if I click on button choose with doubleClick the file, the mouseMoveEvent
start again....
Regards,

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

11

Friday, December 23rd 2005, 9:24am

Check at which position does the move occur. BTW. Why do you want to eliminate this mouse move?

12

Friday, December 23rd 2005, 10:08am

mouseMoveEvent & QFileDialog

when I click on 'load' button appear a openFileDialog where I choose
a file. If I choose a file with doubleClick (and behind the mouse there is myWidgetGL), mouseMoveEvent of myWidgetGl start. I'd like mouseMoveEvent called for other aim. But if change position in the screen of openFileDialog (not be in front of myWidget) and my doubleClick is out of myWidget, mouseMoveEvent don't start. I don't know what I can do....
Thanks
Regards,

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

13

Friday, December 23rd 2005, 1:17pm

RE: mouseMoveEvent & QFileDialog

So why don't you block the event while the other dialog is active? Before opening the file dialog, notify glwidget to ignore mousemoves somehow (you have to implement this! for example by applying an event filter which denies all mousemove events sent to the object), then process the dialog, and afterwards reenable mousemove processing (for example by removing the event filter).

14

Friday, December 23rd 2005, 5:14pm

eventFilters

ok.But wich object? button load? openFileDialog? instance of glWidget?
I isntall this inside the function of mainForm that is called by 'load' button:

Source code

1
this->loadTexture->installEventFilter(this->myWidget1);

After this is called:

Source code

1
2
3
4
5
bool MyWidget::eventFilter(QObject* obj, QEvent* e)  {
      if (( e->type() == QEvent::MouseButtonDblClick) && (e->type() ==     
           QEvent::MouseButtonDblClick) && (e->type() == QEvent::
           MouseButtonRelease)) 
}

but I don't understand obj what is! 'load' button isn't a QObject...
e->type isn't any QEvent I code above
Thanks.
Regards,

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

15

Friday, December 23rd 2005, 5:55pm

RE: eventFilters

Quoted

Originally posted by mickey
but I don't understand obj what is! 'load' button isn't a QObject...

Every widget is also a QObject, because QWidget inherits QObject class.

Source code

1
2
3
4
if (( e->type() == QEvent::MouseButtonDblClick) && (e->type() ==     
           QEvent::MouseButtonDblClick) && (e->type() == QEvent::
           MouseButtonRelease)) 
}
What you wrote here means: if e type is equal to QEvent::MouseButtonDblClick and it's equal to QEvent::MouseButtonRelease then do something.

This will never happen since QEvent::MouseButtonDblClick != QEvent::MouseButtonRelease.

16

Friday, December 23rd 2005, 7:27pm

EventFilters

sorry mouseRelease....
This code filter out MouseDoubleClick Event? Is it so?

Source code

1
2
3
4
5
6
7
8
9
bool MyWidget::eventFilter(QObject* obj, QEvent* e) {
	if (( e->type() == QEvent::MouseButtonDblClick) {
		  cout << "mo";
		  return  true;
	  } 
	else {
		cout << "false\n";
		return false;
	}
Regards,

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

17

Friday, December 23rd 2005, 9:07pm

RE: EventFilters

Yes. All double clicks which are passed to the filter. Please note that you should check for particular object, as there may be other objects using the filter too.

18

Friday, December 23rd 2005, 9:21pm

EventFilters

I write this code:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
bool MyWidget::eventFilter(QObject* obj, QEvent* e) {
      cout << "filter\n";
      if (obj == this) {
		cout << "myWidget\n";
		printf("%d",*obj);
		cout << "loadT\n";
		if (( e->type() == QEvent::MouseButtonDblClick) || ( e->type() == 
                           QEvent::MouseMove)) {
		  cout << "mo";
		  return  true;
		} 
		else {
			cout << "false\n";
			return false;
		}
	}

but don't work. I open QFileDialog and I close it but obj isn't 'this' (myWidget)
Regards,

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

19

Friday, December 23rd 2005, 10:12pm

RE: EventFilters

From which object did you invoke the installEventFilter() method?

20

Friday, December 23rd 2005, 11:29pm

EventFilters

I invoke installevent within a SLOT of MainForm class

Source code

1
this->load->installEventFilter(this->myWidget1);

'this->load' is 'load' button of MainForm
Regards,