QScrollArea scrolling down not up
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-p...ion-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?
Re: QScrollArea scrolling down not up
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?
1 Attachment(s)
Re: QScrollArea scrolling down not up
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.
Re: QScrollArea scrolling down not up
Wait a minute. QTextBrowser is already scrollable. What's the point placing it inside a QScrollArea?
Re: QScrollArea scrolling down not up
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:
Code:
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");
Re: QScrollArea scrolling down not up
Turns out the culprit was the fact that I had:
Code:
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
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.