PDA

View Full Version : QScrollArea scrolling down not up



ntp
14th August 2008, 21:42
I have a very strange problem. I have a widget (my own, inherits QWidget and a .ui file). It has a tab splitterwhich contains a button and a tree widget on the left and a QScrollArea in the right. I put a QTextBrowser into the QScrollArea.

The problem is that I can only scroll down using the slider. If I want to scroll up, I have to right mouse click in the slider area and use the context sensitive menu.

I searched for QScrollArea and didn't notice anything like my issue. I noticed the thread:
http://www.qtcentre.org/forum/f-qt-programming-2/t-window-customization-10848.html
and the dialog that does contain this widget has no window title and receives mouse events. However I added "event->ignore();" to all the mouse events and nothing changed.

Has anyone run into anything like this?

wysota
14th August 2008, 23:48
I'm not able to reproduce your problem using Qt Designer. Could you post the ui file (or a small compilable application) here that would show what you mean?

ntp
15th August 2008, 01:26
I have attached a small example. It does work in the designer but once you actually make an app, it doesn't. It doesn't matter whether or not I put the text browser in the QScrollArea through designer or through code.

I can even reproduce it with a regular titlebar and no mouse events.

I have noticed the same behavior on windows and mac and I am using the latest 4.4.1.

Thanks.

jpn
19th August 2008, 19:51
Wait a minute. QTextBrowser is already scrollable. What's the point placing it inside a QScrollArea?

ntp
19th August 2008, 20:08
I have lots of other custom widgets and a tab widget in the scroll area. The text widget is inside of the tab widget. The example that I gave you is just a minimized version of what I do to duplicate the problem.

I just substituted the following code in MainWidget.cpp to use a QLabel instead of QTextBrowser and I still see the problem:



QLabel* label = new QLabel(this);
scrollArea_->setWidget(label);
label->setText("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\ n16\n17\n18\n19\n20\n");

ntp
20th August 2008, 17:23
Turns out the culprit was the fact that I had:

setStyleSheet("background-color: rgb(240,240, 240)");

in the mainDialog.cpp

This propagated to widgets that cannot be styled this way. In order to style the scrollbar, it looks like I am going to have to style each part of the scrollbar.
stylesheet description for scrollbar (http://doc.trolltech.com/4.4/stylesheet-examples.html#customizing-qscrollbar)

I was hoping that I could set the color of my entire application in one call but it looks like I am going to have to be a little more detailed than that.