Results 1 to 2 of 2

Thread: hangup vertical scroll bar in qtextedit

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    Warsaw/Poland
    Posts
    56
    Thanks
    8
    Thanked 4 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default hangup vertical scroll bar in qtextedit

    I've got textedit and i want display menu so i do:

    Qt Code:
    1. void MainTextEdit::mousePressEvent(QMouseEvent *event)
    2. {
    3. if (parent->isActiveWindow() == false) QTextEdit::mousePressEvent(event); // prevent bug
    4.  
    5. if (event->button() == Qt::RightButton)
    6. {
    7. if (this->textCursor().selectedText().isEmpty() == true) // if nothing selected
    8. {
    9. QTextCursor cursor = cursorForPosition(event->pos());
    10. cursor.select(QTextCursor::WordUnderCursor);
    11. if (!cursor.selectedText().isEmpty())
    12. {
    13. QString strText = cursor.selectedText();
    14. int iPos = cursor.position() - cursor.block().position(); // cursor.positionInBlock()
    15.  
    16. cursor.select(QTextCursor::BlockUnderCursor);
    17. QString strBlock = cursor.selectedText().trimmed();
    18. QStringList strlBlock = strBlock.split(" ");
    19.  
    20. QString strWord = strlBlock[1];
    21.  
    22. // channel
    23. if (strText.at(0) == '#')
    24. {
    25. ...
    26. QMenu *menu = new QMenu(strChannel);
    27. ...
    28. menu->popup(mapToGlobal(event->pos()));
    29. }
    30.  
    31. // nick
    32. if ((iPos > 11) && (iPos < 11+2+strWord.length()))
    33. {
    34. ...
    35. QMenu *menu = new QMenu(strNick);
    36. ...
    37. menu->popup(mapToGlobal(event->pos()));
    38. }
    39. }
    40. }
    41. }
    42. }
    43.  
    44. QTextEdit::mousePressEvent(event);
    45. }
    To copy to clipboard, switch view to plain text mode 

    this code is working good but sometimes vertical scroll bar stops, and moving it to bottom by mouse don't work - because after adding next line of text it back to "saved"? position ...

    maybe I forget to add something ?
    Last edited by mero; 16th February 2011 at 22:06.

Similar Threads

  1. How to disable vertical scroll bar in QTableWidget
    By grsandeep85 in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2009, 11:07
  2. QListView with conditional vertical automatic scroll
    By jmesquita in forum Qt Programming
    Replies: 2
    Last Post: 1st August 2009, 03:09
  3. Vertical scroll bar, but resizable horizontal content
    By minimoog in forum Qt Programming
    Replies: 0
    Last Post: 14th January 2009, 20:51
  4. vertical scroll bar in Qt box.
    By rajveer in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2008, 07:41
  5. Vertical Scroll Bar - Style Sheet
    By vishesh in forum Qt Programming
    Replies: 2
    Last Post: 18th September 2007, 19:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.