PDA

View Full Version : QScrollBar subControlRect ignores orientation Qt5.9.1



Oleg21
19th September 2017, 19:57
Hi everyone!

I recently started using Qt. Everything was fine, but once I worked with QScrollBar.
I needed to find out the coordinates of the Sub Controls.
For example, to find out the QStyle :: SC_ScrollBarSubLine coordinates and dimensions, I used the following code:



QStyleOptionSlider *opt = new QStyleOptionSlider;
opt->initFrom(scrollBar1);

QRect r = scrollBar1->style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSubLine);


This code works great with a horizontal scrollbar.
Because with a vertical scrollbar, it is not possible to get coordinates and dimensions QStyle :: SC_ScrollBarSubLine.
More precisely, sizes and coordinates can be obtained,
but they will be equal to the size and coordinates of the QStyle :: SC_ScrollBarSubLine horizontal scroll bar.

Take a look at the pictures. They graphically show what I'm trying to find out.

Maybe some of you already encountered similar problems. Tell me how to solve them?

1258212581