How to connect slot to QScrollBar::rangeChanged signal?
-
Hi!
I using Image Viewer Example
How to connect slot to QScrollBar::rangeChanged signal?
It's not work:connect(scrollArea, &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
-
@Mikeeeeee said in How to connect slot to QScrollBar::rangeChanged signal?:
It's not work:
Why don't you say what happens?
Do you expect others to guess?
How does ImageViewer::updateSize signature look like? -
I want to get the QScrollBar status change signal and then I want to get different sizes of QScrollBar.
void ImageViewer::updateSize() { /* qDebug()<<scrollArea->horizontalScrollBar()->value() <<scrollArea->horizontalScrollBar()->maximum() //<<scrollArea->horizontalScrollBar()->sliderPosition() //тоже, что и value <<scrollArea->horizontalScrollBar()->minimum() <<scrollArea->horizontalScrollBar()->pageStep();*/ }
-
@Mikeeeeee
you should post your error message,from the naming of things, my guess is,
scrollArea
is aQScrollArea
not aQScrollBar
-
@Mikeeeeee You are aware that rangeChanged has two parameters?
Also, you still don't want to tell us what is exactly the problem?! Error message? -
QScrollArea *scrollArea;
if i do this:
connect(scrollArea, &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
I get error: no matching member function for call to 'connect'
As with any change QScrollArea *scrollArea tun ImageViewer::updateSize()? -
Hi
You are not using correct parameters.
its
rangeChanged(int min, int max)
so your slot should also have those.void ImageViewer::updateSize( int min, int max )
{
...
and you say
connect(scrollArea, &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
but its not scrollArea that has rangeChanged, its its scrollbar
so it should be
connect(scrollArea->verticalScrollBar(), &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
and thats for the vertical scrollbar, thre is also a horizontal.