Re: vertical scrollbar width
Subclass QScrollBar and override sizeHint and minimumSizeHint. Then set your custom scroll bar to the scroll area.
Regards
Re: vertical scrollbar width
My class:
Code:
{
public:
protected:
};
and then in my code:
Code:
pendingPane->setVerticalScrollBar(new CScrollBar(pendingPane));
Seems OK to me, but the only effect is to make the scrollbar invisible (and no bigger).
And no, those are not the sizes I ultimately want, but I figured it would be noticable.
Derek
Re: vertical scrollbar width
Do you want to increase the size of every scroll bar or just one? Because it might be simpler to implement a proxy style that would just return an increased pixel metric for the proper enum (QStyle::PM_ScrollBarExtent).
Re: vertical scrollbar width
:)
Yes, but the only problem is that sizeHint and minimumSizeHint are virtual public and const in QWidget, not virtual protected.
Regards
Re: vertical scrollbar width
Quote:
Originally Posted by
marcel
Yes, but the only problem is that sizeHint and minimumSizeHint are virtual public and const in QWidget, not virtual protected.
New class:
Result is the same however. The scrollbar is invisible, and the space it would have been taking up is no bigger.
Derek
Re: vertical scrollbar width
Quote:
Originally Posted by
wysota
Do you want to increase the size of every scroll bar or just one? Because it might be simpler to implement a proxy style that would just return an increased pixel metric for the proper enum (QStyle::PM_ScrollBarExtent).
It would be for all of them.
I know I was reading recently about proxy styles, but now can't find the information. Can you point me to something about that?
Thanks,
Derek
Re: vertical scrollbar width
Never mind. I found the information I had before in the Qt Centre Wiki.
Derek
Re: vertical scrollbar width
Quote:
Originally Posted by
drkbkr
New class:
Result is the same however. The scrollbar is invisible, and the space it would have been taking up is no bigger.
By the way, these do still not match the signatures of QWidget::sizeHint() and QWidget::minimumSizeHint(). They should be const methods. You're not overriding but overloading and therefore these methods never get called.
Re: vertical scrollbar width
Thanks.
That makes them bigger, but they're still not visible, just a blank area on the right side of the scroll area.
Any ideas?
Re: vertical scrollbar width
I tried a proxy style, using the following pixel metric method in the header file:
Code:
int pixelMetric
(PixelMetric metric,
const QStyleOption* option
= 0,
const QWidget* widget
= 0) const {
if (metric == PM_ScrollBarExtent)
{
qDebug("RETURNING SIZE FOR SCROLL BAR");
return 45;
}
else if(metric == PM_ScrollBarSliderMin)
{
qDebug("RETURNING MIN HEIGHT FOR SLIDER\n");
return 500;
}
return ProxyStyle::pixelMetric(metric, option, widget);
}
I see both qDebug statements many times but the returned values do not seem to be honored.
I remember that when I was trying to adjust the height of tabs in a tab widget, I looked at the code for the tab widget and tab bar classes and there was comment indicating that tab widget would ignore any attempts to resize the bar and would always make it as small as it could. Maybe this is another case like that.
Derek
Re: vertical scrollbar width
Code:
int MyStyle
::pixelMetric(PixelMetric metric,
const QStyleOption* option,
const QWidget* widget
) const {
if (metric == PM_ScrollBarExtent)
return 45;
return ProxyStyle::pixelMetric(metric, option, widget);
}
{
if (type
== QStyle::CT_ScrollBar) return contentsSize;
return ProxyStyle::sizeFromContents(type, option, contentsSize, widget);
}
Re: vertical scrollbar width
Well, that changes the size of the area that the scroll bar should be using, but the scroll bar is still the same size, aligned left in that area.
1 Attachment(s)
Re: vertical scrollbar width
Which style are you using? That works fine for me with plastique style as a base. Are you sure you don't have "left overs" somewhere in your code?
Edit: Seems to work with windows and cleanlooks styles too.
2 Attachment(s)
Re: vertical scrollbar width
I'm using plastique as well.
For the record, it's Qt 4.2.1 on Ubuntu.
Here's a compilable example, and the results that I see on my laptop.
Derek
Re: vertical scrollbar width
Sorry, I don't have any other version than 4.3.0 installed on this machine so I cannot test with others but I can confirm that at least with 4.3.0 it's fine.. :)
Re: vertical scrollbar width
Quote:
Originally Posted by
jpn
Sorry, I don't have any other version than 4.3.0 installed on this machine so I cannot test with others but I can confirm that at least with 4.3.0 it's fine.. :)
My example is fine? Or your test is? I don't think I missed anything in my example, but who knows...
1 Attachment(s)
Re: vertical scrollbar width
Quote:
Originally Posted by
drkbkr
My example is fine? Or your test is? I don't think I missed anything in my example, but who knows...
Yours is fine, too. Just for for the records, I'm running Xubuntu 7.04 on this crappy old machine I've got. :)
Re: vertical scrollbar width
Thanks for your help.
Building 4.3 right now.
Re: vertical scrollbar width
Works as expected with 4.3.0
Derek