Hi!
I wrote a dialog to input valid car plates (Portuguese format: http://pt.wikipedia.org/wiki/Matr%C3...is_em_Portugal )using Qt Designer. It works just fine.

Then i tried to write it again, but now not using Qt Designer.
This second version works but i get the following message :

Qt Code:
  1. Starting /home/torrao/Desktop/v7/automovel_sem_designer/automovel_sem_designer
  2. QWidget::setTabOrder: 'first' and 'second' must be in the same window
  3. QWidget::setTabOrder: 'first' and 'second' must be in the same window
  4. /home/torrao/Desktop/v7/automovel_sem_designer/automovel_sem_designer exited with code 0
To copy to clipboard, switch view to plain text mode 

This must be an insignificant detail ... but i would apreciate some help

The code:
IdDoAutomovel.h
Qt Code:
  1. #ifndef IDDOAUTOMOVELDIALOG_H
  2. #define IDDOAUTOMOVELDIALOG_H
  3.  
  4. #include <QDialog>
  5.  
  6. class QLabel;
  7. class QLineEdit;
  8. class QString;
  9. class QRegExp;
  10.  
  11. class IdDoAutomovelDialog : public QDialog
  12. {
  13. Q_OBJECT
  14.  
  15. public:
  16. IdDoAutomovelDialog(QWidget *parent = 0);
  17.  
  18. private slots:
  19. void on_lineEdit_textChanged();
  20.  
  21. private:
  22. QLabel *label;
  23. QLineEdit *lineEdit;
  24. QSpacerItem *horizontalSpacer;
  25. QPushButton *okButton;
  26. QPushButton *cancelButton;
  27. QStringList *listaMatriculasValidas;
  28. QVBoxLayout *verticalLayout;
  29. QHBoxLayout *horizontalLayout;
  30. QHBoxLayout *horizontalLayout_2;
  31. };
  32.  
  33. #endif // IDDOAUTOMOVELDIALOG_H
To copy to clipboard, switch view to plain text mode 

IdDoAutomovel.cpp
Qt Code:
  1. #include <QtGui>
  2.  
  3. #include "IdDoAutomovelDialog.h"
  4.  
  5. IdDoAutomovelDialog::IdDoAutomovelDialog(QWidget *parent):QDialog(parent){
  6. //Label
  7. label = new QLabel("&MatrÃ*cula:");
  8.  
  9. //Line Edit
  10. lineEdit = new QLineEdit;
  11.  
  12. //Buddyes
  13. label->setBuddy(lineEdit);
  14.  
  15. //Spacer
  16. horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  17.  
  18. //OK Button
  19. okButton = new QPushButton("Ok");
  20. okButton->setEnabled(false);
  21.  
  22. //CANCEL Button
  23. cancelButton = new QPushButton("Cancel");
  24. cancelButton->setObjectName(QString::fromUtf8("cancelButton"));
  25.  
  26. //Validar a matrÃ*cula introduzida ( http://pt.wikipedia.org/wiki/Matr%C3%ADculas_autom%C3%B3veis_em_Portugal )
  27. listaMatriculasValidas = new QStringList;
  28. listaMatriculasValidas->append("[A-Za-z]{2,2}[-][0-9]{2,2}[-][0-9]{2,2}");
  29. listaMatriculasValidas->append("[0-9]{2,2}[-][0-9]{2,2}[-][A-Za-z]{2,2}"); //or
  30. listaMatriculasValidas->operator <<("[0-9]{2,2}[-][A-Za-z]{2,2}[-][0-9]{2,2}");
  31. QRegExp regExp(listaMatriculasValidas->join("|"));
  32. lineEdit->setValidator(new QRegExpValidator(regExp, this));
  33.  
  34. //Definir acções
  35. connect(lineEdit, SIGNAL(textChanged(const QString &)),
  36. this, SLOT(on_lineEdit_textChanged()));
  37.  
  38. connect(okButton, SIGNAL(clicked()),
  39. this, SLOT(accept()));
  40. connect(cancelButton, SIGNAL(clicked()),
  41. this, SLOT(close()));
  42.  
  43. //layout Dialog
  44. horizontalLayout = new QHBoxLayout;
  45. horizontalLayout_2 = new QHBoxLayout;
  46. verticalLayout = new QVBoxLayout;
  47.  
  48. horizontalLayout->addWidget(label);
  49. horizontalLayout->addWidget(lineEdit);
  50.  
  51. horizontalLayout_2->addItem(horizontalSpacer);
  52. horizontalLayout_2->addWidget(okButton);
  53. horizontalLayout_2->addWidget(cancelButton);
  54.  
  55. verticalLayout->addLayout(horizontalLayout);
  56. verticalLayout->addLayout(horizontalLayout_2);
  57.  
  58. //Tab order
  59. QWidget::setTabOrder(lineEdit, okButton);
  60. QWidget::setTabOrder(okButton, cancelButton);
  61.  
  62. setWindowTitle("MatrÃ*cula");
  63. setLayout(verticalLayout);
  64. }
  65.  
  66. void IdDoAutomovelDialog::on_lineEdit_textChanged(){
  67. okButton->setEnabled(lineEdit->hasAcceptableInput());
  68. }
To copy to clipboard, switch view to plain text mode 

Thanks