Unsolved Scroll Area
-
Hello Everyone,
What I'm trying to do, is when on scroll area is moved, another scroll area moves by the same amount. Is this possible?
Thanks in advance -
Hi
Yes you can do something likeconnect(view1->horizontalScrollBar(), SIGNAL(valueChanged(int)), view2->horizontalScrollBar(), SLOT(setValue(int))); connect(view2->horizontalScrollBar(), SIGNAL(valueChanged(int)), view1->horizontalScrollBar(), SLOT(setValue(int)));
https://stackoverflow.com/questions/12304293/synchronize-scrollbar-in-qt
-
Hi, i've implemented that and I'm sure that will work. But i seem to have a problem when compiling. I have added this in my widget.cpp file and and gives me an error message saying 'No matching member function for call 'connect''.
Any ideas?
thanks -
@Alfie-Anil
HI
its hard to guess on without the code.
Could be one of the parameters or that it's not inside a QObject based
class. -
Hi this is the code. I've noticed that when I don't use the 'ui->' in a connect it works. however, do have to use it... This is the code:
```
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setWidgetResizable(true);
ui->scrollArea_2->setWidgetResizable(true);QWidget *widget = new QWidget(); QWidget *newwidget = new QWidget(); ui->scrollArea->setWidget(widget); ui->scrollArea_2->setWidget(newwidget); QPushButton *button = new QPushButton(); qDebug() << "Initialised widget to scroll area"; connect(ui->scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->scrollArea_2->verticalScrollBar(), SLOT(setValue(int)));
-
Hi
Its one of the sneaky ones.
you need to add
#include "QScrollBar"in top file file for it to know the type returned by
->verticalScrollBar()It does give a hit with "incomplete" type
but still sneaky :)
-
@mrjj
Thank you. I've now got a new problem that says the program ended unexpectedly, when i set a style sheet for anything in the widget.ui
Any ideas? Thanks -
@Alfie-Anil
You right clik in the UI file and use Change stylesheet or what you do ? -
I right click on the scroll area that I have added and then click change stylesheet.
-
I've just got another problem. It says QObject::connect: No such signal QObject::valueChanged(int)
anyideas?
connect(ui->scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->scrollArea_2->verticalScrollBar(), SLOT(setValue(int)));
-
Hi
It compiles for me.
Try to do a build -> clean and
rebuild all.