PDA

View Full Version : Connect 2 QScrollArea



sev75
30th May 2014, 19:39
Hi,
I have a QScrollArea "scrollMain" and I want to use a QScrollArea "scrollVertical" and a QScrollArea "scrollHorizontal" to control "scrollMain". You understand that "scrollVertical" and "scrollHorizontal" will contain headers for datas in "scrollMain".
I tried :

connect(ScrollArea1->verticalScrollBar(),valueChanged(int),ScrollArea2->verticalScrollBar(),setValue(int));
but I got "undefined functions" messages.
I tried to create my own functions without success.
It seems "value" parameter from verticalScrollBar() and horizontalScrollBar() are unreachable.

Do you have an issue?
Thanks

Lesiok
30th May 2014, 20:01
You have forgotten the words SIGNAL and SLOT

connect(ScrollArea1->verticalScrollBar(),SIGNAL(valueChanged(int)),Scro llArea2->verticalScrollBar(),SLOT(setValue(int)));

sev75
31st May 2014, 14:04
no matching function for call to 'Timeline::connect(QScrollBar*, const char*, QScrollBar*, const char*)'
ui->scrollMain->verticalScrollBar(),SLOT(setValue(int)));

This is the complete line :

connect(ui->scrollVertical->verticalScrollBar(),SIGNAL(valueChanged(int)),
ui->scrollMain->verticalScrollBar(),SLOT(setValue(int)));

anda_skoa
31st May 2014, 14:41
Do you have the include for QScrollBar?

Cheers,
_

sev75
31st May 2014, 15:19
Indeed, I forgot the include. Thanks very much