Hi, i've created a widget with a button and a spinBox, i want to set a value in the spinBox when i'm going to click on the button. Down here the code.

ui_spinForm.h --> created with QT Designer
Qt Code:
  1. #ifndef UI_SPINFORM_H
  2. #define UI_SPINFORM_H
  3.  
  4. #include <QtCore/QVariant>
  5. #include <QtGui/QAction>
  6. #include <QtGui/QApplication>
  7. #include <QtGui/QButtonGroup>
  8. #include <QtGui/QHBoxLayout>
  9. #include <QtGui/QPushButton>
  10. #include <QtGui/QSpinBox>
  11. #include <QtGui/QWidget>
  12.  
  13. class Ui_spinForm
  14. {
  15. public:
  16. QWidget *widget;
  17. QHBoxLayout *hboxLayout;
  18. QSpinBox *spinBox;
  19. QPushButton *addPushButton;
  20.  
  21. void setupUi(QWidget *spinForm)
  22. {
  23. if (spinForm->objectName().isEmpty())
  24. spinForm->setObjectName(QString::fromUtf8("spinForm"));
  25. spinForm->resize(258, 52);
  26. widget = new QWidget(spinForm);
  27. widget->setObjectName(QString::fromUtf8("widget"));
  28. widget->setGeometry(QRect(60, 10, 133, 29));
  29. hboxLayout = new QHBoxLayout(widget);
  30. hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
  31. hboxLayout->setContentsMargins(0, 0, 0, 0);
  32. spinBox = new QSpinBox(widget);
  33. spinBox->setObjectName(QString::fromUtf8("spinBox"));
  34.  
  35. hboxLayout->addWidget(spinBox);
  36.  
  37. addPushButton = new QPushButton(widget);
  38. addPushButton->setObjectName(QString::fromUtf8("addPushButton"));
  39.  
  40. hboxLayout->addWidget(addPushButton);
  41.  
  42.  
  43. retranslateUi(spinForm);
  44.  
  45. QMetaObject::connectSlotsByName(spinForm);
  46. } // setupUi
  47.  
  48. void retranslateUi(QWidget *spinForm)
  49. {
  50. spinForm->setWindowTitle(QApplication::translate("spinForm", "Try a spinbox", 0, QApplication::UnicodeUTF8));
  51. addPushButton->setText(QApplication::translate("spinForm", "Add", 0, QApplication::UnicodeUTF8));
  52. Q_UNUSED(spinForm);
  53. } // retranslateUi
  54.  
  55. };
  56.  
  57. namespace Ui {
  58. class spinForm: public Ui_spinForm {};
  59. } // namespace Ui
  60.  
  61. #endif // UI_SPINFORM_H
To copy to clipboard, switch view to plain text mode 

spinForm.h
Qt Code:
  1. #include "ui_spinForm.h"
  2.  
  3. class spinForm : public QWidget, public Ui::spinForm
  4. {
  5. Q_OBJECT
  6.  
  7. public:
  8. spinForm(QWidget *parent = 0);
  9.  
  10. private slots:
  11. void setSpinBoxValue();
  12.  
  13. private:
  14. Ui::spinForm ui;
  15. };
To copy to clipboard, switch view to plain text mode 

spinForm.cpp
Qt Code:
  1. #include <QtGui>
  2. #include "spinForm.h"
  3.  
  4. spinForm::spinForm(QWidget *parent):QWidget(parent)
  5. {
  6. connect(addPushButton, SIGNAL(clicked()), this, SLOT(setSpinBoxValue()));
  7. ui.setupUi(this);
  8. }
  9.  
  10. void spinForm::setSpinBoxValue()
  11. {
  12. spinBox->setValue(45);
  13. }
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QApplication>
  2.  
  3. #include "ui_spinForm.h"
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. QApplication app(argc, argv);
  8. QWidget *widget = new QWidget;
  9. Ui::spinForm ui;
  10. ui.setupUi(widget);
  11. widget->show();
  12. return app.exec();
  13. }
To copy to clipboard, switch view to plain text mode 

When i compile it i don't have any problems, i can lunch the widget but when i click on the button nothing happen.
I've tried to put spinBox->setValue(45) in the constructor too...
I've checked the code a lot of time but i haven't catch any errors, maybe cos i'm a newbie!
Thanks ppl for your support