Thanks for the reply, I tried your suggestion but got the following error: passing 'const QString' as 'this' argument discards qualifiers [-fpermissive]

This is the code I wrote for it
read.h
Qt Code:
  1. #ifndef READ_H
  2. #define READ_H
  3.  
  4. #include <QDialog>
  5.  
  6.  
  7. namespace Ui {
  8. class read;
  9. }
  10.  
  11. class read : public QDialog
  12. {
  13. Q_OBJECT
  14.  
  15. friend class beastiary;
  16.  
  17. public:
  18. const QString nvalue;
  19. void ulk();
  20. explicit read(QWidget *parent = 0);
  21. ~read();
  22.  
  23. private:
  24. Ui::read *ui;
  25.  
  26. };
  27.  
  28.  
  29. #endif // READ_H
To copy to clipboard, switch view to plain text mode 

beastiary.cpp
Qt Code:
  1. void beastiary::on_listWidget_itemClicked(QListWidgetItem *item)
  2. {
  3. const QString nvalue = ui->listWidget->currentItem()->text();
  4. read red;
  5. red.nvalue=nvalue;
  6. red.setModal(true);
  7. red.exec();
  8. red.ulk();
  9.  
  10. }
To copy to clipboard, switch view to plain text mode 

read.cpp
Qt Code:
  1. void read::ulk()
  2. {
  3. QFile file (nvalue);
  4. if (!file.open(QFile::ReadOnly | QFile::Text))
  5. {
  6. QMessageBox::warning (this, "Error", "File Could not Be Opened");
  7. }
  8. QString line;
  9. QTextStream in(&file);
  10. while (!in.atEnd())
  11. {
  12. line = in.readLine();
  13. ui->lineEdit_name_r->setText(ui->lineEdit_name_r->text()+line);
  14. qDebug() <<line;
  15. }
  16. }
To copy to clipboard, switch view to plain text mode