ich bekomme dauernd ein Fehlermeldung, sobald ich mit meiner QMap-Variable arbeiten möchte.
Ich befürchte, dass ich das Prinzip der statischen Methoden und Variablen noch nicht so ganz verstanden habe.
Hier mal ein bisschen Quellcode:
settings.h
Code: Alles auswählen
#ifndef SETTINGS_H
#define SETTINGS_H
#include <qmap.h>
class Settings
{
//Q_OBJECT
public:
Settings( );
~Settings( );
static bool read();
private:
QMap<QString, QString> mapSettings;
};
#endif // SETTINGS_HCode: Alles auswählen
#include <qfile.h>
#include "../headers/settings.h"
Settings::Settings()
{
}
bool Settings::read()
{
QFile file ( "ini_files/program_settings.ini" );
if ( file.open ( IO_ReadOnly ) ) {
QTextStream stream ( &file );
QString line;
while ( !stream.atEnd() ) {
line = stream.readLine().latin1();
QStringList split = QStringList::split( "=", line, true );
mapSettings[split[0]] = split[1];
} file.close();
return true;
}
else {
return false;
}
}
Settings::~Settings()
{
// no need to delete child widgets, Qt does it all for us
}Code: Alles auswählen
if( Settings::read() ) QMessageBox::information( this, "MsgBox", "OPEN!", "OK");sources/../headers/settings.h: In static member function âstatic bool Settings::read()â:
sources/../headers/settings.h:19: error: invalid use of member âSettings::mapSettingsâ in static member function
sources/settings.cpp:26: error: from this location
make: *** [.obj/settings.o] Fehler 1
Ich nehme an, dass es ein Anfänger-Fehler ist.
Da ich aber momentan nicht weiter weiß, wende ich mich mal an euch!
Danke im Voraus!