Tutorial Page Two
In this example, we will be creating a function, creating a second component
and exploring the techniques for connections signals to slots from within the
Signal/Slot Editor's framework.
Hopefully you're coming from the previous demo, if it bored you and you came
here you can pull up from that last from you QtEZ distribution in the
demos/tutorial/ directory.
Anyway, assuming you're coming from the last demo, let's add a push button to
the layout. Center that just a bit underneath the image from earlier. Then like
we did before setup the button with a caption of "Hide" and give it some
interesting colour in the background, I chose light green.
Then double click on project1 (your top level component). This will bring the
Source Editor up. Project1 should be showing
in the leftmost combo box, from this dialog click on file | new member. Then in
the defintion box enter "void toggleShow()" then make sure "Public Slot" is
checked, "Virtual Member" is not checked, and finally "Declared/Defined here"
is checked. Then hit save. You'll find yourself in the equivlant of
project1::toggleShow(), so in the editer on the bottom enter the following
source code:
if(label1->isVisible())
{
    button1->setText("Show");
    label1->hide();
}
else
{
    button1->setText("Hide");
    label1->show();
}
So what you've created now is a locally defined member that is under the
heading of a "Public Slot". Ok, we're on to the final steps, we need to
make the connection, so go to your
MenuBar and you'll see two comboboxes and
two listboxes. In the left most combobox select button1. Then in the left listbox select "void clicked()", now you have to chose your slot owner and slot. Make
sure project1 shows in the right combo box, and "void toggleShow()" should be
seen in the right listbox, you'll note a checkbox next to it, and it's white.
The fact that it's white signifies that this that the signal selected
void clicked()) and the that slot are compatible. So to connect you simply
double click on the check box, and it should toggle it to checked, and your
connection is made! Finally select Run | run from the MenuBar.
Project Screen Shot |
Next | Previous |
Contents