Fábio J. Bertinatto wrote:
> Hi,
> 
> Thank you, Eskill.
> 
> Here, the source of my program:

Try this instead:

package default;
import com.trolltech.qt.gui.*;

public class Program extends QMainWindow {     //here eclipse has used
QWidget, but it reported a errror

     Ui_Program ui = new Ui_Program();

     public static void main(String[] args) {
         QApplication.initialize(args);
         Program  testProgram = new Program();
         testProgram.show();
         QApplication.exec();
     }

     public void initSignals(){
         ui.IniciarBuscaButton.clicked.connect(this, "myFunc()");
     }

     public Program() {
         ui.setupUi(this);
         initSignals();
     }

     public void myFunc() {
         System.out.println("My slot is called!");
     }

}

There were a few things wrong in your code:

1. You cannot declare slots, nor write any kind of code in the Ui_Xxx 
files as these are generated from the .jui files and all changes made 
will be overwritten. This is also indicated by the headercomment in the 
file. Above I implemented myFunc() in the Program class instead.

2. When you connect a signal to a slot, you spesify who is the receiver 
of the signal and which function in that instance to call. You passed 
QApplication.instance(), which does not implement a function "myFunc()". 
Since its the Program class that implements the "myFunc()", you need to 
pass the program instance.

-
Gunnar
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to