Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

QGraphicsView and QTreeView synchronous scrolling

$
0
0
Hi, I have coded a GUI where there are QGraphicsView and QTreeView placed, loaded, activated and used. There is a need to move QGraphicsScene, that is “assigned” ( set ) to the QGraphicsView downward and upward ( a.k.a to scroll vertically and horizontally ) using set scroll bars ( scroll bar policy set to both widgets as ScrollBarAlwaysOn ) synchronously with QTreeView, so that when one of the widgets is scrolled on some number of pixels, to scroll the second as well. The widgets scrolling connected using next code:     connect(ui->treeView,SIGNAL(scrolled(int,int)),this,SLOT(scroll_gv(int,int)));     connect(ui->graphicsView,SIGNAL(scrolled(int,int)),this,SLOT(scroll_tv(int,int)));       ...     void MainWindow::scroll_gv(int dx,int dy) {     ui->graphicsView->scroll(dx,dy); }   void MainWindow::scroll_tv(int dx,int dy) {     ui->treeView->scroll(dx,dy); } where the scroll is added to custom classes inherited from QGraphicsView and QTreeView and virtual function reimplemented: void QCTreeView::scrollContentsBy ( int dx, int dy ) {     emit scrolled(dx,dy); }   void qcgraphicsview::scrollContentsBy ( int dx, int dy ) {     emit scrolled(dx,dy); } The problem to correct is next, when I scroll one of the widgets, the second is scrolled as well, but somehow not accurate – all the area of the widget is scrolled and not a widgets internals, The scrolling behavior is recorded in next video clip: https://www.box.com/s/lpaon61oly45fffyu3kn [box.com] Will you hint why such problem, what properties of the widgets to set, how to code correctly in order the synchronous scroll will work ? Thanks in advance for your help.

Viewing all articles
Browse latest Browse all 18427

Trending Articles