Advertisement
Guest User

Untitled

a guest
May 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1.  
  2. ######################################################################
  3. header file:
  4. ######################################################################
  5.  
  6. #ifndef GOTOCELLDIALOG_H
  7. #define GOTOCELLDIALOG_H
  8. #include <QDialog>
  9. #include <QLineEdit>
  10.  
  11.  
  12.  
  13. class GoToCellDialog : public QDialog
  14. {
  15. Q_OBJECT
  16. private:
  17. QLineEdit * lineEdit;
  18. QPushButton * okButton ;
  19. QPushButton * cancelButton ;
  20.  
  21. public:
  22. GoToCellDialog(QWidget *parent = 0);
  23.  
  24. private slots:
  25. void on_lineEdit_textChanged();
  26.  
  27.  
  28. };
  29.  
  30. #endif // GOTOCELLDIALOG_H
  31.  
  32. ######################################################################
  33. cpp file
  34. ######################################################################
  35. #include <QtGui>
  36. #include "gotocelldialog.h"
  37. #include <QtUiTools>
  38.  
  39. GoToCellDialog::GoToCellDialog(QWidget *parent)
  40. : QDialog(parent)
  41. {
  42. //setupUi(this);
  43. QUiLoader loader;
  44. QFile file("gotocelldialog.ui");
  45. file.open(QFile::ReadOnly);
  46. QWidget *formWidget = loader.load(&file, this);
  47. file.close();
  48.  
  49. /*
  50. QLineEdit *lineEdit=formWidget->findChild<QLineEdit *>("lineEdit");
  51. QPushButton *okButton = formWidget->findChild<QPushButton *>("okButton");
  52. QPushButton *cancelButton = formWidget->findChild<QPushButton *>("cancelButton");
  53. */
  54.  
  55. this->LineEdit=formWidget->findChild<QLineEdit *>("lineEdit");
  56. this->okButton=formWidget->findChild<QPushButton *>("okButton");
  57. this->cancelButton=formWidget->findChild<QPushButton *>("cancelButton");
  58.  
  59. QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
  60. lineEdit->setValidator(new QRegExpValidator(regExp, this));
  61. connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
  62. connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
  63. }
  64. void GoToCellDialog::on_lineEdit_textChanged()
  65. {
  66. this->okButton->setEnabled(this->lineEdit->hasAcceptableInput());
  67. }
  68.  
  69.  
  70. ###########################
  71. compilation:
  72. ###########################
  73. /home/melmoth/dev/qt/testgit/home-melmoth-dev-qt-book-chapter2-dynamic/gotocelldialog.cpp:21: error: ‘class GoToCellDialog’ has no member named ‘LineEdit’
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement