[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Problems with QTextEdit
From:       Stefan Bellon <sbellon () sbellon ! de>
Date:       2002-02-26 12:27:37
[Download RAW message or body]

Hi all!

I've just subscribed to this list as I hope this is the correct place for
my question. I've already searched with Google, but I couldn't find any
solution to my problem.

I have a QTextEdit in my application. This loads rather large files with
the following code:

  QFile file( cs.FileName().c_str() );
  if ( file.open( IO_ReadOnly ) ) {
    QTextStream ts( &file );
    te->setText( ts.read() );
  }

Basically it works just fine. But afterwards I want to scroll to a
certain line in that file. I tried with:

  QRect rect = te->paragraphRect( posr );
  te->setContentsPos( 0, rect.top() );

But this doesn't work always. For short files it works. But for long
ones it doesn't. At least this is my assumption. I think the text isn't
in the buffer of the QTextEdit when I want to scroll to that line. Could
this be the problem?

At present I have an *ugly* work-around. I set up a QTimer and when it
fires off after 1 second I do the positioning.

But I don't think this is the proper and correct solution.

I'd very much like to hear from you how to do it properly. :-)

TIA.

Greetings,

Stefan.

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic