Edit Slot ???

Laurent Cortier laurent.cortier at chello.be
Tue Mar 20 21:39:10 GMT 2001


Ok, I can still give a quick try at slots :

In Qt Designer, go to menu Edit, -> Slots...
There, click on New slot button.
Type the name of your slot. I like to use names like this : 
slotRightClickOnTree(), this defines it's a slot, started by
a right click on the tree view object.
Now click Ok.

For my example, you'll need a QListView object. Drop the object 
on your base window and define its size, properties etc. 
Now press F3. 
The cursor should turn into a cross. Now with that cross, 
click on the QListView object (stay clicked !) and drag the 
mouse OUTSIDE your window. I insist on "outside". The border
of your window should highlight in rose. Make sure your window
border is rose before releasing the mouse button, else it
won't work.

Now a dialog box appears, displaying, on the left : 
-the different events that can happen to your widget 
and on the right : 
-the different slots applicable to that event.

Chose one event on the left list, and the corresponding slot
in the right list. Now you should see the combination of the 2
appearing in the botton of that dialog. Click Ok, you're done. 

Just add the slot in your class declaration (.h).
For example :

class mywidget(...) : FrmMainWindow(...)
{
private:
	int blabla;
public:
	mywidget(...);

public slots:
	virtual void slotRightClickOnTree();
}

and in your class definition (.cpp)
For example :

virtual void mywidget::slotRightClickOnTree()
{
   //...
}

Now one last thing : sometimes you choose a signal that has
arguments, in that case the slot function you declared must
include those arguments if you need them !
For example, in our example, the signal rightButtonClicked has
arguments like QWidget *, which is the branch of the tree you
clicked on. To be able to use those arguments, you have to
declare the slot like this :

slotRightClickOnTree(QWidget *) in the Qt Designer, and 

virtual void slotRightClickOnTree(QWidget *); in the class declaration.

Once again, I'm not sure to have been clear... Check the 
women.kde.org tutorials for clearer info :) 

    Laurent Cortier.
Consultant in a free world.
http://www.dsimprove.be

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list