View Single Post
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#123
Originally Posted by nicolai View Post
Ah, funny bug:

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 :-)
function 'stream' does not have a member 'eof' :-P

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");
    QTextStream stream ( &file );
    QString line;
    QHash<QString, QString> variables;
    while( !stream.atEnd()) {
         line = stream.readLine();
         QStringList splittedLine = line.split("=");
         variables.insert(splittedLine.at(0), splittedLine.at(1));
    }
    file.close();
    QString oldfont1 = variables.value("DefaultTextColor");
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE