Hello!
I want to open a text document and to display it on my window. The process has two actions: Opening the file and displaying it on the window. Theoritically, two slots are expected, and two bottons too to be clicked on. But practically, it seems not feasible, since a click on the open button should display the data on the window.
If I click on m_open (see below), a dialog window for the selection of the file will open. I have to selcet this file, click on "open" button of the Dialog window and then the window dissapears.

Line 8 of .cpp: The text erea shoul dremain hide until the data a ready to be display, and will appear with the line 25 of .cpp.
On the line 27 of .cpp file, I display the data on the window. If is not here, I must create another slot, that requires another button, because when I am connecting the button "m_open" to this slot (to open the file) and to another(to display the data), the compilation fails.

My questions:
1- Is there a way to connect the button open of the dialog window (when opening a file) to a slot in order to display my data on my window? If not, how to proceed?

Many thanks in advance.

Here is my code:

.h flie
Qt Code:
  1. #ifndef DEF_MYWINDOW
  2. #define DEF_MYWINDOW
  3.  
  4. #include <QtGui>
  5.  
  6.  
  7. class MyWindow: public QMainWindow
  8. {
  9. Q_OBJECT
  10.  
  11. public:
  12. explicit MyWindow();
  13. virtual ~MyWindow();
  14.  
  15. public slots:
  16. void openFile();
  17.  
  18. private:
  19. QAction *m_open;
  20. QTextEdit *m_myText;
  21. QWidget *m_centralZone;
  22. QMenu *m_menuFile;
  23. QLineEdit *m_openAFile;
  24.  
  25. };
  26.  
  27. #endif // MYWINDOW_H
To copy to clipboard, switch view to plain text mode 

.cpp file
Qt Code:
  1. #include "myWindow.h"
  2.  
  3. myWindow::myWindow()
  4. {
  5. m_menuFile = menuBar()->addMenu("&File");
  6.  
  7. m_myText = new QTextEdit(m_centralZone);
  8. m_myText->setVisible(false);
  9.  
  10. m_open = m_menuFile->addAction("Open a file");
  11.  
  12. m_openAFile = new QLineEdit;
  13.  
  14. connect(m_open, SIGNAL(triggered()), this, SLOT(openFile()));
  15.  
  16.  
  17. setCentralWidget(centralZone);
  18. }
  19.  
  20. void myWindow::openFile()
  21. {
  22. QString file = QFileDialog::getOpenFileName(this, "Information", "Open", "*.text");
  23. m_openAFile->setPlainText(file);
  24.  
  25. myText->setVisible(true);
  26.  
  27. myText->setText(text);
  28.  
  29. }
To copy to clipboard, switch view to plain text mode