You are not logged in.

marcidm

Beginner

  • "marcidm" is male
  • "marcidm" started this thread

Posts: 5

Location: Pordenone, Italy

  • Send private message

1

Sunday, January 8th 2006, 10:23pm

Catch External Events

Hi boys, i'm a newbie about qt and i want to learn how can i catch external events of the main application.
The ploblem is that i don't know how to catch a click mouse (or release mouse) on the desktop for my little kde-applet

Please somebody help me!!!!

  • "impeteperry" is male

Posts: 110

Location: Rhode Island, USA

Occupation: self un-employied

  • Send private message

2

Monday, January 9th 2006, 3:27am

i don't know if this is what you are looking for, but here is a snippit from one of my programs

Quoted

/// mouseDoubleClickEvent()
void dlgMain::mouseDoubleClickEvent(QMouseEvent *event)
{
QString line;

if( actionList.last() == "1,4,n,2,1,5,0,0" )
{
line = drawing->selectItem( event->pos() );
supports->returnUserInput( line );
}
}

The "actionList.last()" is an index code I use in the program. The cursor is on or near a line in a drawing. The QMouse event returns the x,y position of the cursor from which the "supports" module can determin which of the lines in the drawing the cursor is closer to.

I think any of the other mouse events work in a similar fashion. OReilly's Programming with Qt example 2-4 "qscribble" has a lot of readable, useful stuff on varius mouse events.
a helping hand has more than five fingers

This post has been edited 1 times, last edit by "impeteperry" (Jan 9th 2006, 3:37am)


marcidm

Beginner

  • "marcidm" is male
  • "marcidm" started this thread

Posts: 5

Location: Pordenone, Italy

  • Send private message

3

Monday, January 9th 2006, 9:43am

tnx 4 the answer, but it's not what i'm searching 4.

I already know how to manage simple qt events like mouse ClickEvent(QMouse *e) or similar.
I want to know if there is a method that allows to get events from the parent application.

I've created a kde-applet called kwinmenu, and i want that it does something if i click on the desktop, OUTSIDE the widget of my applet.

I know that somewhere on internet there is the answer, but i don't know where to research...

chombium

Trainee

  • "chombium" is male

Posts: 45

Location: Skopje, Macedonia

  • Send private message

4

Monday, January 9th 2006, 6:53pm

Here is a small code snipset that I've used:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* at first define a 
      sigaction that will catch the external signal
*/

struct sigaction SA; 

// qt signal for emitting when the external signal has arrived 

signal:
    void SIgnalVoyAlrt();


// setting the signal handler. VoyAlrt is the external signal handler

SA.sa_handler = VoyAlrt;  
  
// connecting the signal with the handler VOYSIG is the signal
// check KDE doc for your signal 

sigaction(VOYSIG, &SA,0); 
  

// the external signal handler. It just emits QT signal
int VoyAlrt ()
{
  emit SignalVoyAlrt();
}

// connection of QT signal with its Slot
connect(this, SIGNAL(SignalVoyAlrt()), this, SLOT(GetSlot()) ); 

// the slot connected to the signal
int GetSlot ()
{
  // processing...
}


Put the parts from this code appropietely in your program ;)

Hope it helps.
If you have any problems, I'll be glad to help

CHEERS, chombium

marcidm

Beginner

  • "marcidm" is male
  • "marcidm" started this thread

Posts: 5

Location: Pordenone, Italy

  • Send private message

5

Monday, January 9th 2006, 9:22pm

i've searched on internet about sigaction(somesignal, ...); and i don't found any signal that was useful to handle the mouse.
Some days ago i had an idea when i look the behaviour of the k-menu: when you open it and after you click outside the menu it close. So i searched on "KDE Source Cross Reference" (http://lxr.kde.org/) that put all the source code of kde but i didn't found any useful piece of code....

marcidm

Beginner

  • "marcidm" is male
  • "marcidm" started this thread

Posts: 5

Location: Pordenone, Italy

  • Send private message

6

Monday, January 9th 2006, 10:42pm

Maybe I've found a solution.... there's a function called x11EventFilter for QApplication, and says that it gets direct access to all X events that the are received from the X server. The problem that's i don't found any example to how to use this function....

if somebody used this function before or knew where are the examples on the web please help me

This post has been edited 1 times, last edit by "marcidm" (Jan 9th 2006, 10:45pm)


marcidm

Beginner

  • "marcidm" is male
  • "marcidm" started this thread

Posts: 5

Location: Pordenone, Italy

  • Send private message

7

Tuesday, January 10th 2006, 10:32am

hi everybody!

today i've found something about X server events on this pages:

http://tronche.com/gui/x/xlib/event-handling/XSendEvent.html
http://www.xmission.com/~georgeps/docume…r-4.html#events

I think i have to set it properly and then i could catch every event of the desktop....