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

Re: [qt4] QTextCursor

Subject: Re: [qt4] QTextCursor
From: Christopher Thompson
Date: Mon, 24 Oct 2005 13:01:55 -0600
On October 24, 2005 12:53 pm, Duane Hebert wrote:
> Here's the function:
>
> void ReportEngine::AddTableRow(const QString &Buffer)
> {
> Cursor.movePosition(QTextCursor::End);
> table->insertRows(table->rows(),1);

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.

> 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?

> 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, '|'));

> }
> }

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.

-- 
Chris Thompson
Central Sewing Machines
8649 63 Avenue, Edmonton AB, T6E 0E8

--
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>