How to prevent QTextBrowser/QTextDocument from blocking?
I am using QTextBrowser to display some large html pages.
Before I show the data, I spawn a little QMovie loading indicator, and then I call
Code:
{
void showcontent(const QString& s);
};
void ResultBrowser::showcontent(const QString& s)
{
//I use a QTextDocument for my stylesheet
mTextDocument->setHtml(s);
setDocument(mTextDocument);
}
Sadly this causes some blocking which causes the loading indicator to pause. I attempted to call my showcontent function through QtConcurrent::run, but it crashes due to events being triggered from the wrong thread.
Suggestions?
Re: How to prevent QTextBrowser/QTextDocument from blocking?
Well looking back at some other threads on a similar issue I decided to use a timer to insert the text in ~100 character chunks.
This fixes the performance issue *yay*
but sadly the html is not rendered properly when passed in with chunks like this, for example list items <li> don't display on their own lines
Code:
void ResultBrowser::loadContent()
{
if(!mContent.isEmpty() && mCurrentIndex < mContent.size())
{
if(!mTextCursor)
{
}
//No splitting tags
int size = mChunkSize;
int index = mContent.indexOf("<", mCurrentIndex + mChunkSize);
if(index > 0)
{
size = index - mCurrentIndex;
}
QString tmp
= mContent.
mid(mCurrentIndex, size
);
mTextCursor->insertHtml(tmp);
mCurrentIndex += size;
}
else
{
mLoadTimer->stop();
}
}
Is the display issue something that can be overcome? or is this a flawed tactic all together?