PDA

View Full Version : scrolling in QTableWidget



Ursa
10th July 2007, 14:48
Hello!
I have two QTableWidget controls in my dialog. There are equal amount of records in the tables. I would like to synchronize scrolling in these controls - so when I scroll one table I get the same result in another one. Could you give me an idea?

Thanks in advance.

jpn
10th July 2007, 14:53
Provided that dimensions are same, it should be as simple as connecting scrollbars' valueChanged(int) signals to setValue(int) slots:


// establish connections in both directions
connect(table1->horizontalScrollBar(), SIGNAL(valueChanged(int)), table2->horizontalScrollBar(), SLOT(setValue(int)));
connect(table2->horizontalScrollBar(), SIGNAL(valueChanged(int)), table1->horizontalScrollBar(), SLOT(setValue(int)));
// ...and the same for vertical scroll bar

Ursa
11th July 2007, 07:13
Thanks for help. But I get another problem :(
It seems to me everything should be all right but I use this construction and get an error:
C2664: 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 1 from 'QScrollBar *' to 'const QObject *'
I use Win XP, QT 4.3.

jpn
11th July 2007, 07:22
Perhaps a missing #include <QScrollBar> ?