View Full Version : QTextEdit troubles?!

20th February 2006, 18:02

this is not directly an I-have-a-problem-thread, but instead a thread about two things I noticed about QTextEdit.

First, it crashes when you try to load a binary file. I open a binary file with QFile and with the Text Attribute enabled, and showing it in QTextEdit makes my application crash. Is this know to Qt 4.1.0?

Second, the QTextEdit gets very slow when you load more than 100kb. Scrolling and looking at a big file are laggy (I have a 3ghz pc, so on other computers it might be even slower), and doing a simple stringreplacement takes ages (couple of minutes.. dunno, I cancelled after 2 minutes).

Are these known issues? If so, is there any workaround for those which makes use of Qt functions?

Thanks for answers :)

20th February 2006, 18:09
On first question: give your crash-code

21st February 2006, 17:54

the crashcode is really simple, here it is:

/////// file.cpp ///////////
QString readFile ()
// load file
QFile file(getAbsoluteFilename());
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
throw common::error ("Cannot open file: " + getAbsoluteFilename());

// read file and return contents
QTextStream in(&file);

return in.readAll();

// @param contents is the value returned by readFile()
void setTextToQTextEdit (QString uid, QString label, QString contents)
QString log = "fileActionsImpl::createNewDocument: uid = " + uid;
LOG_DEBUG (log.toStdWString());

QTextEdit* tabpage = new QTextEdit; tabpage->setPlainText(contents);

I suppose this is a Qt bug, can anybody confirm this?