![]() |
Cannot create and install application which uses external .txt file.
Hi Everyone!
I am newcomer in programming Qt for my N900. I am writing little first-step-applications for my N900. Everything worked fine till now. I already have own applications for the device, but non of them uses an external data file. Now I am trying to create an application for my N900 which uses an external .txt file. The package is created successfully, the application is installed successfully, however the binary does not see the .txt (maybe it is not in the package?). Something is wrong with the package, I think. I am using MADDE Developer 0.6.72 to create the project skeleton. I am using Qt creator for create the code. After once the code is created successfully then I am running the following commands in MADDE Developer 0.6.72 for the updated skeleton folder created above. I writed the following lines into MADDE developer: << //create project sceleton MADDE-0.6.72 ~/madde - $ mad pscreate -t qt_simple skeleton Skeleton skeleton, type=qtprog created //The code has been edited to read a .txt file. //I created and included into the code the intended Debian folder //structure. MADDE-0.6.72 ~/madde - $ cd skeleton MADDE-0.6.72 ~/madde/skeleton - $ mad qmake MADDE-0.6.72 ~/madde/skeleton - $ mad make MADDE-0.6.72 ~/madde/skeleton - $ mad dpkg-buildpackage >> My goal is to create simple program to my N900 which reads and displays a simple "Hello world!" string from an external file (e.g. from a.txt). Please help! I read all the articles about Debian packaging, but no solution. Thank you for your help! |
Re: Cannot create and install application which uses external .txt file.
For anyone to help you, you need to describe HOW it fails to read the file.
Do you get an error? Some special return value? How do you try to open the file? |
Re: Cannot create and install application which uses external .txt file.
There's no any error message. The program simply starts and right after stops without error messages. The program does not display just a black screen with the program's name in the title bar (this black screen is visible only for a moment, after this everything disapears).
I tried to open the program from the application manager (which is available by tapping its icon next to the time inscription and the battery life indicator) |
Re: Cannot create and install application which uses external .txt file.
Since it is your program, you obviously need to program the error message in it yourself...
In your code, where you read the data file, check for existense of the file with QFile::exists() or by other means. After that check for succesfull opening and reading of the file. And in case of failure, pop up a message box that explains the error and waits for the user to tap it to close it. |
Re: Cannot create and install application which uses external .txt file.
Finally I could start my application on my N900 (removed a bug), but the "Hello world!" message does not display from the external .txt.
Maybe this happens because of the .txt is not included into the package or it is in the wrong path?! My program displays the "Hello world!" message from the .txt if the program is running from Qt creator. |
Re: Cannot create and install application which uses external .txt file.
Quote:
|
Re: Cannot create and install application which uses external .txt file.
I don't know what "qrc resource package" is. Could you please explain it?
Here is my code: Code:
#include<QtCore> And here is my directory structure for the packaging process: http://kepfeltoltes.hu/110213/2011.0...toltes.hu_.jpg |
Re: Cannot create and install application which uses external .txt file.
Furthermore appreciated any help which describes how to create an application for the N900 which reads information from an external data file. :confused::(
|
Re: Cannot create and install application which uses external .txt file.
If you want to protect formatting of code, you use the code tag around it, like so:
Code:
foo(); You have a while-loop where you read all the data into one QString. You could always try to output this string to the console. The file you are trying to read from is indicated by a relative path. For this to work, your program must be placed, and run, from this relative root, containing the "opt" directory. I'd suggest you try to use an absolute path, like "/opt/<whatever>", and see where that takes you. Also, add an else branch to get output to the console if the infile.open call fails. |
Re: Cannot create and install application which uses external .txt file.
My problem has been solved. Now I am able to create external file using applications for my n900.
If you want to create an app for your n900 which reads and displays data from an external file here are the steps what makes you happy: 1. Download and install Qt creator. 2. Set up the qmake and necessary folders in the options. 3. Download and install MADDE Developer. 4. Create the Project and package skeleton with MADDE using the following command: Code:
mad pscreate -t qt_simple yourproject 6. Open the .pro file and add the following lines to it: Code:
INSTALLS += data Data.files is the path where your data.txt exists. Now this is near your .pro file. (The .txt and the .pro is in the same folder.) 7. Open MADDE and navigate to the folder where the .pro file exists and enter the following commands: Code:
mad qmake Enjoy! Thank you for your help! |
All times are GMT. The time now is 21:57. |
vBulletin® Version 3.8.8