[Qgis-developer] plugin text streams and Vector File writers
question
maaza mekuria
sailmcm at yahoo.com
Tue Apr 19 03:36:12 EDT 2011
Hello, again,
I am pluging QGIS on Windows XP using Visual Studio 2008 compiler. I was able to set the user interface of my choice by using QTDesigner. I getting very comfortable and may be even getting hooked with QGIS. If QGIS fails then my research also fails. Such is the stake for me I am looking forward to the new release.
I need help with layer writers ( QgsVectorFileWriter) and stream writers (QTextStream). I know one is QGIS and the other QT. But you guys are expert in both and may help resolve my problems. I want to tackle the QT problem first, I open the text file pointer using the code below (almost the code of the tutorial by Marco.)
QString fileName = QFileDialog::getSaveFileName(0,"Traffic Stress log file name");
if(!fileName.isNull())
{
QFile f(fileName);
if(!f.open(QFile::WriteOnly | QFile::Truncate))
{
QMessageBox::information(0, "error", "Could not open file", QMessageBox::Ok);
return;
}
QTextStream txtStream(&f);
}
I see the file created and yet when I try to write text data out I have not been successful at all. I have stream commands, such as the one below, thrown is at places I want to check the program's progress. They do compile without raising any errors and I also have message boxes with the variables come up during execution of the plugin, but nothing is being written to the disk file.
txtStream <<" Traffic Stress update "<<qsNetlayerName<<endl;
The compilation is working with out an error message. Yet not a single character is written to the file. I added the flush command as in
txtStream.flush();
Yet nothing is being written. What am I missing?
I have other challenges that I have to overcome with the QgsVectorFileWriter also.
It has been very unpredictable with how the data is being written out. I am not sure if it is possible to run the plugin in debug mode on the Windows platform, but that may help newbie QGIS programmers like myself. But it may be too much to ask considering the work that all of you guys have already done. yet, I am asking it may already be possible to run a plugin in debug mode. Is it?
Thank you,
Maaza
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20110419/166f0034/attachment.html
More information about the Qgis-developer
mailing list