connect( table1->verticalScrollBar(), SIGNAL( valueChanged( int ) ), table2->verticalScrollBar(), SLOT( setValue( int ) ) );connect( table2->verticalScrollBar(), SIGNAL( valueChanged( int ) ), table1->verticalScrollBar(), SLOT( setValue( int ) ) );
QObject::connect(ui->namesWidget->verticalScrollBar(), SIGNAL(valueChanged(int)),ui->marksWidget->verticalScrollBar(), SLOT(setValue(int)));
#include "mainwindow.h"#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); // Связываем нужные елементы QObject::connect(ui->namesWidget->verticalScrollBar(), SIGNAL(valueChan),ui->marksWidget->verticalScrollBar(), SLOT(setValue(int)));}
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QObject>#include <QMainWindow>#include <QResizeEvent>#include <QSize>#include <QPoint>#include <QAction>#include <QPushButton>#include <QModelIndex> // Классы оформления#include <Qt>#include <QSplitter>namespace Ui { class MainWindow;}class MainWindow : public QMainWindow { Q_OBJECTpublic: MainWindow(QWidget *parent = 0); ~MainWindow();protected: void changeEvent(QEvent *e); void resizeEvent(QResizeEvent *e); // ------Блок переменных //-----Переменные офрмления формы QSplitter *mainSplitterWidget;private: Ui::MainWindow *ui;};#endif // MAINWINDOW_H
ui->marksWidget->setVerticalScrollBar(ui->namesWidget->verticalScrollBar());