scrolling in QTableWidget
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.
Re: scrolling in QTableWidget
Provided that dimensions are same, it should be as simple as connecting scrollbars' valueChanged(int) signals to setValue(int) slots:
Code:
// 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
Re: scrolling in QTableWidget
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.
Re: scrolling in QTableWidget
Perhaps a missing #include <QScrollBar> ?