July 22, 2011

Evan-XG Evan-XG
Lab Rat
16 posts

Having problerm with QTextBlock::isVisible in QTextEdit


I am writing a simple editor with a line number panel
I want to get the first visible block using this snipet in a slot that is connect to update when the text change and blockCount changed

  1. QTextBlock block=this->TextEditor->document()->begin()
  2. int total_line=this->TextEditor->document()->blockCount();
  3.    int line_ctr=0;
  4.     while(line_ctr<=total_line){
  5.         line_ctr++;
  6.          if(block.isVisible()){
  7.              first_visible_line=block.blockNumber();
  8.              break;
  9.          }
  10.         block=this->TextEditor->document()->findBlockByNumber(line_ctr);
  11.     }

but no matter how first_visible_line is always 1 so block.isVisible() return always true .

I want to keep QTextEdit because I will be adding syntaxe coloring using QSyntaxHil..
Otherwise there is QPlainTextEdit::firstVisibleBlock() but I am not sure if QSyntaxHilighter can work on QPlainTextEdit

Please need help.
Thanks in advance



1 reply

July 22, 2011

Gerolf Gerolf
Hobby Entomologist
3251 posts

Please, don’t double post your stuff.
You already posted the same 7 hours ago with this thread [developer.qt.nokia.com]

If you have additional information, add them to the previous thread.

—> thread closed


Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

  ‹‹ QGLWidget and JPEG      I am unable to link to my own library created using 4.7.3(MinGW) compiler in Qt SDK 1.1.1 Windows ››

You must log in to post a reply. Not a member yet? Register here!