Reading examples and documentation I start to believe that making a custom SIGNAL is not a difficult task. Trying to do it though I realize that I cannot do it!!

Here's a simple example, that if I understand it I will be able to make more custom signals.

  1. a line edit for number A
  2. a line edit for number B
  3. a line edit to present the result of the Multiplication


Here is the corresponding code:


Qt Code:
  1. MyDialog::MyDialog(QWidget *parent)
  2. : QWidget(parent)
  3. {
  4.  
  5. QLineEdit *numberA = new QLineEdit;
  6. QLineEdit *numberB = new QLineEdit;
  7.  
  8. result = new QLineEdit;
  9.  
  10. numberA->setText("1.0");
  11. numberB->setText("1.0");
  12. result->setText("1.0");
  13.  
  14.  
  15.  
  16. vboxlayout = new QVBoxLayout(this);
  17. vboxlayout->addWidget(numberA);
  18. vboxlayout->addWidget(new QLabel("x"));
  19. vboxlayout->addWidget(numberB);
  20. vboxlayout->addWidget(new QLabel("="));
  21. vboxlayout->addWidget(result);
  22.  
  23. setLayout(vboxlayout);
  24. }
  25.  
  26.  
  27. void MyDialog::showMultiplication(QString Astring,QString Bstring)
  28. {
  29. double A,B,Res;
  30. QString ResString;
  31.  
  32.  
  33. A= Astring.toDouble();
  34. B= Bstring.toDouble();
  35.  
  36.  
  37. Res = A*B;
  38.  
  39. ResString.setNum(Res);
  40.  
  41. result->setText(ResString);
  42. }
To copy to clipboard, switch view to plain text mode 

QUESTION:
When the user inserts a new number (anywhere A or B) the multiplication result should be shown directly in the result line edit. The SLOT is obliously the showMultiplication(QString Astring,QString Bstring).

The SIGNAL should be something like
sendNewNumbersForMultiplication(QString ,QString )

BUT, I really cannot understand how to implement it!!
Any help?