QFile, QTextStream, seek()
Hello all,
sorry if I'm making a silly mistake here, but I'm not sure what the best way is.
I'm making a file that has several blocks (at predefined positions). When I create the file, the blocks are not full (i.e. not contiguous). They will be filled later. So, I'd like to skip/extend the file to the position of the next block. Using a seek() and a write just appends and doesn't work.
how do I extend file?
thanks
K
below is the code:
Code:
//make a new file with name in the directory
file = new QFile(path
+"\\"+ name
);
fileName = name;// the file has been opened
else
return -1;
// make a text stream
// write the header
stream.seek(POS_HEADER);
stream << makeHeader();
// write the comments block
QString comments
("This is the standard comments block");
stream.seek( POS_HEADER_COMMENT);
stream << comments;
Re: QFile, QTextStream, seek()
Quote:
Originally Posted by
TheKedge
open(QIODevice::Append)
Maybe you should use QIODevice::ReadWrite to make seek() work?
Re: QFile, QTextStream, seek()
I know why you've had more thanks than posts.
thanks
K
Re: QFile, QTextStream, seek()
Quote:
Originally Posted by
TheKedge
I know why you've had more thanks than posts.
Are you sure he has more thanks than posts? :D
It is true that his thank ratio per thanked post is greater than 1.00 though :)
Re: QFile, QTextStream, seek()
Ahh, I see,
so he has 359 thanks in 2504 posts ... that's only ...erm, 14% useful posts:p
K