PDA

View Full Version : Use of QwwRichTextEdit with scrollbar



user
2nd July 2008, 07:52
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?

wysota
2nd July 2008, 08:18
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.

user
3rd July 2008, 03:16
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:

tb->setGeometry(0,0,width() - verticalScrollBar()->sizeHint().width(), tb->sizeHint().height());
It works but I would like it better if I could change the scrollBar height.
I've tried adding the line:

verticalScrollBar->setGeometry(0,tb->sizeHint().height(), verticalScrollBar()->sizeHint().width, viewport()->size().height() );

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.

wysota
3rd July 2008, 08:33
You can do it through showEvent() or in the constructor (I mean change the geometry of the scrollbar).

user
4th July 2008, 02:53
I think I managed to make it work:

void myClass::resizeEvent( QResizeEvent *re )
{
QwwRichTextEdit::resizeEvent(re);
verticalScrollBar()->setGeometry( 0, tb->sizeHint().height(),
verticalScrollBar()->sizeHint().width(), viewport()->size().height() );
}

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?

wysota
4th July 2008, 11:16
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.