connect(reply, SIGNAL(finished()), this, SLOT(writefile(filename)));
You want to "pass a variable through a connection", but the "finished()" signal does not deliver any string data. For example, in order to send integer value, you would use:
SIGNAL( my_signal(int) )
So, if you want to send a string, you need to declare and use appropriate signal.
accept a filename variable when that signal slot connection is made
2) You dont use variable names when making connections, you need to use datatypes.
This one is not correct:
connect( SIGNAL( a_signal( const QString& myString ), ... ), ...
but this is ok:
connect( SINGAL( a_signal( const QString& ), ... ), ...

Maybe read this first:
Signals and slots

pass on to writefile(std::string)
Why are you using a slot that accepts std::strings ? Maybe better question would be, why are you using std::strings in qt-based app, where you have such lovely QString interface ?

-------

edit: Zlatomir was faster