Why isn't the std::ifstream approach working? Post your code and an explanation of the problem.
Why isn't the std::ifstream approach working? Post your code and an explanation of the problem.
I tried this on my GUI application ....Actually it should load the content of input.txt file in textedit when I clicked the button....but result does not come.ie the the text file is not loaded...and no errors are observed
Qt Code:
void MainWindow::on_pushButton_clicked() { QString line; while (!in.atEnd()) { line = in.readAll(); ui->textEdit->setPlainText(line); } file.close(); }To copy to clipboard, switch view to plain text mode
Last edited by wysota; 15th March 2011 at 11:34. Reason: missing [code] tags
Why don't you check that the file actually gets opened?
I again tried to display my text file in ...but now in textbrowser...this time my program ran succcessfully and I and i browsed to my text file and it did displayed the content of my textfile but..ERROR:nly single line is diplayed....please suggest me ...to improve my code
Qt Code:
void MainWindow::on_pushButton_clicked() { { QString line; while (!in.atEnd()) { line = in.readLine(); ui->textBrowser->setText(line); //ui->textEdit->setPlainText(line); } file.close(); } }To copy to clipboard, switch view to plain text mode
Last edited by wysota; 15th March 2011 at 12:40. Reason: missing [code] tags
can you explain (in own words!) what happens in this snippet?
Qt Code:
while (!in.atEnd()) { line = in.readLine(); ui->textBrowser->setText(line); }To copy to clipboard, switch view to plain text mode
Ok I got it correct!!!
U don't know how to load a map using text file in qt creator
Last edited by jerkymotion; 15th March 2011 at 12:45.
that's funny
actually I was asking about how to load a map using text file in qt creator????
wysota might explode soon
jerkymotion, if you mean qt creator then he is right. If you mean Qt, then look at what felixB asked you and think about what you are doing there! It is the reason you are getting your result.
why do you want to load such a map in Qt Creator?
Ok it's my school project
I wanted load a map for navigation purpose....so that if i clicked in the map it gives the co-ordinate value of that position and I want to send those value to my serial port...that's it
so I had an idea about loading a map via text file but I am finding it difficult in qt because I am newbie to Qt creator
We have a rule on this forum that we can't give full solutions to school projects. We can only help you go in the right direction.
Your approach with QFile looked correct but you dropped it for some reason. Maybe try going back to it and expand it. Think about an algorithm for reading the map. If necessary, take a piece of paper and a pencil and "emulate" the process or reading a file.so I had an idea about loading a map via text file but I am finding it difficult in qt because I am newbie to Qt creator
Last edited by wysota; 15th March 2011 at 16:38.
Bookmarks