Hey people,
I started a small application and this is what I have so far:
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5. #include <QPushButton>
  6. #include <QFileDialog>
  7. #include <QLineEdit>
  8.  
  9.  
  10. namespace Ui {
  11. class MainWindow;
  12. }
  13.  
  14. class MainWindow : public QMainWindow
  15. {
  16. Q_OBJECT
  17.  
  18. public:
  19. explicit MainWindow(QWidget *parent = 0);
  20. ~MainWindow();
  21. QPushButton * btn;
  22. QLineEdit * line;
  23.  
  24.  
  25. private slots:
  26. void open();
  27.  
  28. private:
  29. Ui::MainWindow *ui;
  30. };
  31.  
  32. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QFileDialog>
  4.  
  5.  
  6. MainWindow::MainWindow(QWidget *parent) :
  7. QMainWindow(parent),
  8. ui(new Ui::MainWindow)
  9. {
  10. ui->setupUi(this);
  11.  
  12. btn = new QPushButton("Open!");
  13. btn->show();
  14. line = new QLineEdit;
  15. line->show();
  16. QObject::connect(btn, SIGNAL(clicked()), this, SLOT(open()));
  17. }
  18.  
  19. MainWindow::~MainWindow()
  20. {
  21. delete ui;
  22.  
  23. }
  24.  
  25. void MainWindow::open()
  26. {
  27. fd = new QFileDialog;
  28. fd->show();
  29.  
  30. }
To copy to clipboard, switch view to plain text mode 
And main.cpp
Qt Code:
  1. #include <QtGui/QApplication>
  2. #include "mainwindow.h"
  3. #include <QPushButton>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. QApplication a(argc, argv);
  8. MainWindow w;
  9. w.show();
  10. return a.exec();
  11. }
To copy to clipboard, switch view to plain text mode 

So,the idea was to press the button,open the file dialog,select a text file and:
1)Its directory should appear in the line edit(I don't know how to take the directory and put it in the lineedit)
2)Its content should appear in a text edit.

And one more,all the widgets(btn and line)appear in different boxes...how to make them be in the mainwindow?

Thank you.