In the MainWindow.ui i have a cancel button (no problem with, because i added a close() slot with gui), but if i want to add a myFunction to other button??
You would need to subclass the button in order to add a method. However, you normally don't need to, since you can just add myFunction to MainWindow and connect the clicked() signal to your slot.

/home/maurelio/pgm/qt-sdk/esercizi/FirstGui/mainwindow.h:21: error: ISO C++ forbids declaration of ‘connectAction’ with no type
This error usually happens when you forget to add an #include for the class. However, I don't think connectAction is a class but I guess it's an object, so you probably forgot to specify the class name. e.g.:

Qt Code:
  1. ...
  2. public slots:
  3. void connectNet();
  4.  
  5. private:
  6. QAction *connectAction;
  7. ...
To copy to clipboard, switch view to plain text mode 

/home/maurelio/pgm/qt-sdk/esercizi/FirstGui/mainwindow.cpp:9: error: ‘connectButton’ was not declared in this scope
This means there's no such connectButton in MainWindow. If you added it in Qt Designer, you would have to use ui->connectButton instead. You could make MainWindow a subclass of Ui::MainWindow. This way you could directly access connectButton without needing to add "ui->".

Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5. #include <QtNetwork>
  6. #include "ui_mainwindow.h"
  7.  
  8. class MainWindow : public QMainWindow, private Ui::MainWindow
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13. MainWindow(QWidget *parent = 0);
  14.  
  15. public slots:
  16. void connectNet();
  17. };
  18.  
  19. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include <QtGui>
  2. #include "mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent)
  5. : QMainWindow(parent)
  6. {
  7. setupUi(this);
  8.  
  9. connect(connectButton, SIGNAL(clicked()), this, SLOT(connectNet()));
  10. }
  11.  
  12. void MainWindow::connectNet()
  13. {
  14. //Some Stuff;
  15. }
To copy to clipboard, switch view to plain text mode