[Qt-interest] Create a new file

Raphael Meloni raphael.meloni at gmail.com
Thu Jun 25 03:09:30 CEST 2009


Use QSettings with QSettings::IniFormat to manipulate a ini file.

or

Use this source.

QFile file("santaris.ini");
if (file.open(QIODevice::ReadWrite))
{
   QTextStream out(&file);
   out<<"Hello World";
}
else
{
    QFile::FileError fError = file.error();
    switch(fError)
    ...
}
file.close();

Jeffrey Brendecke escreveu:
> What is the current directory for the main process?
> 
> It seems myProcess may have a different working directory than the one that 
> the file "santaris.ini" is being created in as myProcess is a separate 
> process from the process in which the .ini-file is created in.
> 
> Try using absolute paths in all instances.
> 
> --------------
> On Sunday 14 June 2009 23:39:42 Stefanos Antaris wrote:
>> Hello.I am trying to create a new .ini file that doesn't exist.But i
>> can't manage it.I am just trying to make it using QFile but it doesn't
>> work.Or i can't  work it.Here is my code.
>>     myProcess = new QProcess(this);
>>     myProcess->setWorkingDirectory("/Users/santaris/Desktop/omnetpp");
>>     ui->logTextBrowser->append(myProcess->workingDirectory());
>>     QFile file("santaris.ini");
>>     file.open(QIODevice::ReadWrite);
>>     QTextStream out(&file);
>>     out<<"Hello World";
>>
>>     file.close();
>>     if(!file.exists())
>>         ui->logTextBrowser->append("No exist");
>>     myProcess->start("./test");
>>
>> I just want to make the santaris.ini in order to run the ./test
>> simulation that i have.But i can't run it at all
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 



More information about the Qt-interest-old mailing list