An sich sieht das so aus:
Header:
Code: Alles auswählen
#ifndef PROGRAMLAUNCHER_H
#define PROGRAMLAUNCHER_H
#include <QObject>
#include <QProcess>
#include <QTemporaryFile>
class ProgramLauncher : public QObject
{
Q_OBJECT
public:
ProgramLauncher ( QObject *parent = 0 );
~ProgramLauncher();
public slots:
loaded ( int handle, QByteArray data );
private:
BinaryLoader *loader
QTemporaryFile tmpfile;
};
#endifCode: Alles auswählen
#include "ProgramLauncher.h"
#include <QByteArray>
#include <QDebug>
ProgramLauncher::ProgramLauncher ( QObject *parent )
: QObject ( parent )
{
loader = new BinaryLoader ( );
connect ( loader, SIGNAL ( binaryLoaded ( int, QByteArray ) ), this, SLOT ( loaded ( int, QByteArray ) ) );
}
void loaded ( int handle, QByteArray data )
{
qDebug() << handle;
Q_UNUSED ( data );
tmpfile = new QTemporaryFile ( QString ( "qXXXXXX" ) );
}
ProgramLauncher::~ProgramLauncher()
{
}Wenn ich nun aber die Erzeugung des Objekts direkt im Slot mache, also nciht in der Header-Datei, geht es. Wenn ich es im Header mache, nimmt er auch (entgegen der Dokumentation) auch keinen this-pointer an:g++ hat geschrieben:ProgramLauncher.cpp:45: error: assignment of function 'FILE* tmpfile()'
ProgramLauncher.cpp:45: error: cannot convert 'QTemporaryFile*' to 'FILE* ()()' in assignment
Ich steh auf dem Schlauch, aber notfalls lege ich das Ding auch erst beim Aufruf des Slots an...g++ hat geschrieben:ProgramLauncher.cpp:45: error: invalid use of 'this' in non-member function
C167