Hello,

I am a newbie in QT. I tried making a browse button to display file dialog but on complie time it gives an error:

"pushButton was not declared in this scope"

I have included the appropriate headers.

Here is the header:
Qt Code:
  1. #ifndef PT_H
  2. #define PT_H
  3.  
  4. #include <QWidget>
  5. #include<QPushButton>
  6. #include "pt.h"
  7.  
  8. namespace Ui {
  9. class pt;
  10. }
  11.  
  12. class pt : public QWidget {
  13. Q_OBJECT
  14. public:
  15. pt(QWidget *parent = 0);
  16. ~pt();
  17.  
  18. public slots:
  19. void browse();
  20.  
  21. protected:
  22. void changeEvent(QEvent *e);
  23.  
  24. private:
  25. Ui::pt *ui;
  26. };
  27.  
  28. #endif // PT_H
To copy to clipboard, switch view to plain text mode 

Here is main.cpp
Qt Code:
  1. #include <QtGui/QApplication>
  2. #include<QtGui/QPushButton>
  3. #include<QFileDialog>
  4. #include "pt.h"
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. QApplication a(argc, argv);
  9. pt w;
  10. w.show();
  11. return a.exec();
  12. }
To copy to clipboard, switch view to plain text mode 

and finally the pt.cpp (pt my project name )
Qt Code:
  1. #include<QtGui/QApplication>
  2. #include<QFileDialog>
  3. #include<QtGui>
  4. #include<QtGui/QPushButton>
  5. #include "pt.h"
  6. #include "ui_pt.h"
  7.  
  8. pt::pt(QWidget *parent) :
  9. QWidget(parent),
  10. ui(new Ui::pt)
  11. {
  12. ui->setupUi(this);
  13.  
  14. connect( pushButton, SIGNAL( clicked() ), this, SLOT( browse() ) );
  15. }
  16.  
  17. pt::~pt()
  18. {
  19. delete ui;
  20. }
  21.  
  22. void pt::browse()
  23. {
  24. QString path;
  25.  
  26. path = QFileDialog::getOpenFileName(
  27. this,
  28. "Choose a file to open",
  29. QString::null,
  30. QString::null);
  31.  
  32. ui->lineEdit->setText( path );
  33. }
  34.  
  35. void pt::changeEvent(QEvent *e)
  36. {
  37. QWidget::changeEvent(e);
  38. switch (e->type()) {
  39. case QEvent::LanguageChange:
  40. ui->retranslateUi(this);
  41. break;
  42. default:
  43. break;
  44. }
  45. }
To copy to clipboard, switch view to plain text mode 

Somebody please help me on this !!
Thanks.