Results 1 to 6 of 6

Thread: Use of QwwRichTextEdit with scrollbar

  1. #1
    Join Date
    May 2007
    Location
    Australia
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Use of QwwRichTextEdit with scrollbar

    I'm using QwwRichTextEdit in my software but I have a small problem:
    When I resize my window and not all the ToolBar buttons are visible I get an extension button as the last item in the toolbar (ok).
    If the contents of my document doesn't fit the window I get scrollBars (ok).
    But if both happen together - extension button for the toolbar and scrollbar for the document - the extension button is hidden under the scrollbar and I can access all the buttons only if I resize the window (effectively removing the extension button).

    I would like the vertical scrollbar to not reach all the way to the top of the QwwRichTextEdit widget but just under the toolbar. Is this possible?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Use of QwwRichTextEdit with scrollbar

    Quote Originally Posted by user View Post
    But if both happen together - extension button for the toolbar and scrollbar for the document - the extension button is hidden under the scrollbar and I can access all the buttons only if I resize the window (effectively removing the extension button).
    Yes, I can confirm that bug.

    I would like the vertical scrollbar to not reach all the way to the top of the QwwRichTextEdit widget but just under the toolbar. Is this possible?
    Yes, I think so. There are two choices - either I correct it or you probably have to reimplement the resize event and change the scrollbar geometry or toolbar geometry there.

  3. #3
    Join Date
    May 2007
    Location
    Australia
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Use of QwwRichTextEdit with scrollbar

    I had to create a new class inheriting the QwwRichTextEdit since I needed a few more buttons on the toolBar so I just tried now to reimplement the resizeEvent function.
    I changed the toolBar width in the setGeometry command:
    Qt Code:
    1. tb->setGeometry(0,0,width() - verticalScrollBar()->sizeHint().width(), tb->sizeHint().height());
    To copy to clipboard, switch view to plain text mode 
    It works but I would like it better if I could change the scrollBar height.
    I've tried adding the line:
    Qt Code:
    1. verticalScrollBar->setGeometry(0,tb->sizeHint().height(), verticalScrollBar()->sizeHint().width, viewport()->size().height() );
    To copy to clipboard, switch view to plain text mode 

    This command worked but only after resizing the window. When I view the textEditor for the first time I already have a document displayed and a scrollBar but it's height is not adjusted. I don't know via which command to call the resizeEvent function and from where.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Use of QwwRichTextEdit with scrollbar

    You can do it through showEvent() or in the constructor (I mean change the geometry of the scrollbar).

  5. #5
    Join Date
    May 2007
    Location
    Australia
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Use of QwwRichTextEdit with scrollbar

    I think I managed to make it work:
    Qt Code:
    1. void myClass::resizeEvent( QResizeEvent *re )
    2. {
    3. QwwRichTextEdit::resizeEvent(re);
    4. verticalScrollBar()->setGeometry( 0, tb->sizeHint().height(),
    5. verticalScrollBar()->sizeHint().width(), viewport()->size().height() );
    6. }
    To copy to clipboard, switch view to plain text mode 

    I don't know why but it seems I need to call QwwRichTextEdit::resizeEvent(re) before changing the scrollbar geometry (and not setGeometry and than resizeEvent, like I was trying to do) otherwise the first time I view the document (with scrollbar already there) the geometry values are correct but are not displayed properly on the screen.

    Now that this works and I can see the scrollbar and extension button I have a problem with the extension button. I can only click the button when the mouse is on the right border of the button. This does not happen if I have no vertical scrollbar - than I can click anywhere on the extension button. Could that be another bug?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Use of QwwRichTextEdit with scrollbar

    If you call the base class implementation after your own, the base will move the scrollbars to where it wants, that's why you need to call it before your instructions.

    As for the extension - hard to say, not a bug in my code, for sure. The thing you can do is to make sure the toolbar doesn't extend over the scrollbar, it should be fine then.

Similar Threads

  1. QScrollarea events transferring to scrollbar
    By babu198649 in forum Qt Programming
    Replies: 15
    Last Post: 6th September 2013, 22:33
  2. Scrollbar not working fine way
    By santosh.kumar in forum Qt Programming
    Replies: 0
    Last Post: 15th April 2008, 04:58
  3. Treeview scrollbar not updating when inserting rows
    By Khal Drogo in forum Qt Programming
    Replies: 11
    Last Post: 29th November 2007, 13:13
  4. GraphicsView/GraphicsScene: scrollbar policy Qt::ScrollBarAsNeeded
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2007, 13:15
  5. about scrollbar style
    By qtopiahooo in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 13:34

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.