PDA

View Full Version : File size limitation in qt



radhika bp
20th October 2014, 09:51
I have a text file size of 3.33MB which i need to render in the text browser. But only 1MB of text file data is read and rendered.
It would be helpfull i could know the text file size limit to render in qt.

I am using the following code.


#include "file.h"
#include "ui_file.h"
#include<QFile>
#include<QTextStream>
#include<QMessageBox>

file::file(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::file)
{
ui->setupUi(this);
}

file::~file()
{
delete ui;
}

void file::on_pushButton_clicked()
{
QFile file ("D:\\Users\\aisu1452\\Thales_db_frgbsa9.pc");

if(!file.open(QIODevice :: ReadOnly))
{
QMessageBox :: information(0,"info", file.errorString());
}
else
{
QTextStream in (&file);
ui->textBrowser->setText(in.readAll());
}

}

wysota
20th October 2014, 10:05
There is no "text file size limit" in Qt.

yeye_olive
20th October 2014, 12:35
Have you tried QTextBrowser::setSource() to let the widget load the document as it sees fit, instead of loading the whole contents in RAM?

d_stranz
20th October 2014, 19:52
If your text file contains a null character (0x0), the QString returned by readAll() will be effectively truncated at that point. Likewise, I think QTextBrowser will stop loading when it hits a null.