Es geht um das eigentliche Thema des Threads.
Das auslesen der Config friert die gui ein.
Deswegen hab ich ein Thread erstellt, hat auch ganz gut geklappt, der Thread wird ausgefuehrt, aber in der run Funktion brauch ich Zugriff auf Objekte der Main Klasse.
Also hab ich mir SIGNALE erstellt, die ich an den jeweiligen Stellen emitiere, und dann in der Main versuche zu connecten. Allerdings krieg ich das connecten nich hin, hier mal der code:
Hier ist die Thread Klasse:
Code: Alles auswählen
class logThread : public QThread
{
Q_OBJECT
public:
void run();
signals:
QString getSettings(const char*);
int logLinesValue();
int maxLinesValue();
const char* qtcharLog(QString xml);
void paintLog(const char *t);
void status(const char*, unsigned int);
};
#endifCode: Alles auswählen
void logThread::run()
{
QFile logFile(emit getSettings("logpath"));
QFile logFile(Gui_Settings::self(this)->mergeConfig("logpath"));
if (logFile.open(QIODevice::ReadOnly) == TRUE) {
QTextStream openedLogFile( &logFile );
QString wholeFile="a";
int lines = (emit logLinesValue());
int max = (emit maxLinesValue());
// int lines = Gui_Settings::self(this)->logLines->value();
// int max = Gui_Settings::self(this)->maxLines->value();
int hits=0;
char logContent[lines*150];
strcpy(logContent,"\0");
TODO this function freezes the gui
register int count=0;
while(!wholeFile.isNull() && hits < lines && count < max) {
wholeFile = openedLogFile.readLine(150);
// if(!wholeFile.isNull() && wholeFile.contains(Gui_Settings::self(this)->mergeConfig("keyword"), Qt::CaseSensitive)) {
if(!wholeFile.isNull() && wholeFile.contains(emit getSettings("keyword"), Qt::CaseSensitive)) {
// strcat(logContent,Gui_Settings::self(this)->qtcharO(wholeFile));
strcat(logContent,(emit qtcharLog(wholeFile)));
strcat(logContent,"\n");
hits++;
}
count++;
}
if(strlen(logContent) != 0) {
emit paintLog(logContent);
emit status("LogFile succesfully scanned",40000);
// PaintArea(logContent);
// statusBar()->showMessage ("LogFile succesfully scanned",40000);
}
else {
emit paintLog("No entries in LogFile");
emit status("No entries in LogFile",40000);
// PaintArea("No entries in LogFile");
// statusBar()->showMessage ("No entries in LogFile",40000);
}
logFile.close();
}
else {
emit paintLog("Cant open LogFile");
emit status("No LogFile found",40000);
// PaintArea("Cant open LogFile");
// statusBar()->showMessage ("No LogFile found",40000);
}
}Code: Alles auswählen
//TODO read File reverse
void QscannerMain::checkLog()
{
statusBar()->showMessage ("Start searching the Log...",40000);
logThread thread;
thread.start(QThread::NormalPriority);
sleep(2);
}Code: Alles auswählen
connect(logThread::thread, SIGNAL(getSettings(const char*)), this, SLOT(mergeConfig(const char*)));
connect(logThread::thread, SIGNAL(logLinesValue()), this->logLines , SLOT(value()));
connect(logThread::thread, SIGNAL(maxLinesValue()), this->maxLines , SLOT(value()));
connect(logThread::thread, SIGNAL(qtcharLog(QString xml)), Gui_Settings::self(this), SLOT(qtcharO(QString xml)));
connect(logThread::thread, SIGNAL(paintLog(const char *t)), this, SLOT(PaintArea(const char *t)));
connect(logThread::thread, SIGNAL(status(const char*, unsigned int)), statusbar, SLOT(showMessage(const char*, unsigned int)));Code: Alles auswählen
scannermain.cpp:131: error: no matching function for call to `QscannerMain::
connect(<unknown type>, const char[26], QscannerMain* const, const char[26])EDIT: Naja das wars wohl nich selbst wenn ich "logThread thread;" direkt vor den connects defeniere klappts nich
Waere echt nett wenn mich jemand aufklaeren koennte was da falsch laeuft! Dann pack ich auch ein solved beim titel rein