PDA

View Full Version : Jambi - Eclipse - Designer - Slots



ronnyf
31st January 2009, 16:50
Hi folks,

I recently started (again) playing around with Qt (last time was 3.3 I guess). And I have come across an issue I would like to confirm with you.
This is what I did initially:


Create a Qt Jambi Project in Eclipse (3.4)
Create a Qt Jambi Design Form (MainWindow)
Created a simple UI (with Eclipse Designer Interface)


Now I understand that I need to connect the button (pushButton_add) to a slot. This is where I am facing the issue. I do not seem to be able to do so.

After a bit of googling I tried to hard code the connection in the TestMain.java file that has been generated buy the designer (TestJava.jui). The problem is now, when I change my UI, the Designer generates a new TestMain.java, overwriting my edits (inconvenient to say the least!). I am now required to rely on TestMainImpl.java for slot definition?


public class TestMainImpl extends QMainWindow {
TestMain ui = new TestMain();

public static void main (String[] args) {
...initialize();
...
...exec();
}

public TestMain() {
ui.setupUi(this);
//is this the right place for that?!?!?!?!
ui.pushbutton_add.clicked.connect(this, "pushButton_add_clicked()");
}


That is sad but ok, if it has to be like this, I can deal with it. What is the Signal/Slot editor for then anyways? Am I doing something wrong; did I misunderstand a concept? Please help me out here, your help is greatly appreciated.

Good day

Ronny

jacek
31st January 2009, 18:44
You have to derive a class from TestMain and add all the code you need there. The other way is to use aggregation instead of inheritance.

See: http://doc.trolltech.com/4.4/designer-using-a-component.html

ronnyf
2nd February 2009, 16:35
Yes, you are absolutely right. More intensive reading would have solved my issue by itself.
Thanks for your help.