qt-interest@trolltech.com
[Top] [All Lists]

Re: [qt4] QTextCursor

Subject: Re: [qt4] QTextCursor
From: "Duane Hebert"
Date: Mon, 24 Oct 2005 15:33:26 -0400
"Christopher Thompson" <chris@xxxxxxxxxxxxxxxxx> wrote in message
news:200510241301.55612.chris@xxxxxxxxxxxxxxxxxxxx

> Are you just inserting a single row?  In Qt 3.x, I found that if you are
> inserting lots of rows, it _kills_ performance to insert them one at a
time.

It's due to the interface.  This is for a report generator and the calling
object needs to write them one at a time.


> > int numColumns = table->columns();
> > for(int i = 0; i < numColumns; ++i) {
> > QTextTableCell cell = table->cellAt(table->rows() - 1,i);
>
> Why are you copying the cell instead of just using a reference?

Probably just stupidity.  This is copy/paste from the Scribe stuff
in QtAssistant.  Moving the delecation for the cell
out of the loop has no noticeable affect though.

> > Cursor = cell.firstCursorPosition();
> > Cursor.insertText(QGetArg(Buffer,i + 1,'|'));
>
> For that matter, why not rewrite the inside of your for loop as:
>  table->cellAt(table->rows() - 1,
> i).firstCursorPosition().insertText(QGetArg(Buffer, i + 1, '|'));

This seems more logical.  I'll try this but as I say the bottleneck appears
to be in the free call inside of QTextCursor.  I wonder why it needs a free
on an insert call.

> Please be warned that I haven't tried this out myself.  Additionally, it
isn't
> likely to help you all that much if the problem really does lie in
> insertText() taking a long time.

That's what it looks like.  I'm installing the latest 4.1 snapshot though
to see if this is any better.

Thanks.

--
To unsubscribe - send "unsubscribe" in the body to 
qt-interest-request@xxxxxxxxxxxxx
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>