![]() |
Re: Need assistance from QT programmer
Quote:
#include <QtCore> #include <QMainWindow> #include <QProgressDialog> #include <QColorDialog> #include <QHash> #include <QFile> #include <QTextStream> But still have the errors. |
Re: Need assistance from QT programmer
Quote:
if (!file.open (IO_ReadOnly)) // didn't work QTextStream stream ( &file ); .... while( !stream.eof() ) { stream is only declared in the "if-block" scope. The same like this. if (!file.open (IO_ReadOnly)) QTextStream stream ( &file ); .... while( !stream.eof() ) { or if (!file.open (IO_ReadOnly)) { QTextStream stream ( &file ); } .... while( !stream.eof() ) { would produce an error :-) |
Re: Need assistance from QT programmer
Quote:
So I tried this: while( !stream.atEnd()) And got no errors. However the function does not work, I get nothing into QString called "oldfont1" when trying to do it like this: Code:
QFile file("/etc/hildon/theme/colors.config"); |
Re: Need assistance from QT programmer
Quote:
Code:
file.open(QFile::ReadOnly); Or does a QFile open the file directly after declaring it? I thought that.. if it's not opened, nothing is read, and the QString stays empty. |
Re: Need assistance from QT programmer
Quote:
I thought it opens the file automaticly, but obviously it didn't :) |
Re: Need assistance from QT programmer
Rule number one: look from API first. :)
Usually there are examples how to use the class, for example QFile. |
Re: Need assistance from QT programmer
Quote:
Problem (for me) is that most of the docs are written in the way that the writer assumes that reader already knows how things are working and therefore they are lacking the basic guides like: 1. create QFile "object" or what ever it's called 2. you must open the file with separate command so type file.open 3. do something with the file you just opened etc etc.... But I'm slowly learning and thanks to you guys for answering my questions over and over gain. |
Re: Need assistance from QT programmer
Quote:
Quote:
|
Re: Need assistance from QT programmer
Quote:
Anyways, it's now working and getting closer to first release :) |
Re: Need assistance from QT programmer
What do you not understand exactly?
In the example they don't use QTextStream::readLine(), they use QFile::readLine(), which is inherited from QIODevice. The difference is that QTextStream::readLine() returns a QString and QFile::readLine() returns a qint64 (QByteArray in the example), but I don't know anything about qint64 or QByteArrays, so I'll stick with QTextStrem::readLine() :p |
All times are GMT. The time now is 06:18. |
vBulletin® Version 3.8.8