Results 1 to 5 of 5

Thread: QGraphicsView and QTreeView synchronous scrolling

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QGraphicsView and QTreeView synchronous scrolling

    1.

    "
    Why not just connect valueChanged() signals of vertical (or horizontal, where appropriate) scrollbars of both widgets to their setValue() counterparts?
    "
    -- Tnx, recently connected next way:

    Qt Code:
    1. connect(ui->treeView->verticalScrollBar(),SIGNAL(valueChanged(int)),this,SLOT(scroll_gv_v(int)));
    2. connect(ui->graphicsView->verticalScrollBar(),SIGNAL(valueChanged(int)),this,SLOT(scroll_tv_v(int)));
    3.  
    4. //...
    5.  
    6.  
    7. void MainWindow::scroll_gv_v(int dy)
    8. {
    9. qDebug()<<"*** in scroll_gv_v, dy = "<<dy<<endl;
    10.  
    11.  
    12. ui->graphicsView->verticalScrollBar()->setValue(dy);
    13.  
    14. ui->graphicsView->verticalScrollBar()->setSliderPosition(dy);
    15.  
    16. ui->graphicsView->verticalScrollBar()->update();
    17.  
    18. ui->graphicsView->verticalScrollBar()->repaint();
    19.  
    20. ui->graphicsView->update();
    21.  
    22. ui->graphicsView->repaint();
    23.  
    24. qDebug()<<"*** in scroll_gv_v, tree view scroll bar value = "<<ui->treeView->verticalScrollBar()->value()<<endl;
    25.  
    26. qDebug()<<"*** in scroll_gv_v, graphics view scroll bar value = "<<ui->graphicsView->verticalScrollBar()->value()<<endl;
    27.  
    28. }
    29.  
    30. void MainWindow::scroll_tv_v(int dy)
    31. {
    32. qDebug()<<"*** in scroll_tv_v, dy = "<<dy<<endl;
    33.  
    34.  
    35. ui->treeView->verticalScrollBar()->setValue(dy);
    36.  
    37. ui->treeView->verticalScrollBar()->setSliderPosition(dy);
    38.  
    39. ui->treeView->verticalScrollBar()->update();
    40.  
    41. ui->treeView->verticalScrollBar()->repaint();
    42.  
    43. ui->treeView->update();
    44.  
    45. ui->treeView->repaint();
    46.  
    47. qDebug()<<"*** in scroll_tv_v, tree view scroll bar value = "<<ui->treeView->verticalScrollBar()->value()<<endl;
    48.  
    49. qDebug()<<"*** in scroll_tv_v, graphics view scroll bar value = "<<ui->graphicsView->verticalScrollBar()->value()<<endl;
    50.  
    51. }
    To copy to clipboard, switch view to plain text mode 


    then qDebug() shows, that the verticalScrollBar() value of the counterparts stays the same after the signals called and finished and counterpart scrollbars of the connected widgets do not move at all then. Why the value of the counterpart verticalScrollBar() wasn't changed then in such implementation ?


    2.

    +
    when I changed
    Qt Code:
    1. void MainWindow::scroll_gv(int dx,int dy)
    2. {
    3. ui->graphicsView->scroll(dx,dy);
    4. }
    5. void MainWindow::scroll_tv(int dx,int dy)
    6. {
    7. ui->treeView->scroll(dx,dy);
    8. }
    To copy to clipboard, switch view to plain text mode 

    to:
    Qt Code:
    1. void MainWindow::scroll_gv(int dx,int dy)
    2. {
    3. ui->graphicsView->viewport()->scroll(dx,dy);
    4. }
    5.  
    6. void MainWindow::scroll_tv(int dx,int dy)
    7. {
    8. ui->treeView->viewport()->scroll(dx,dy);
    9. }
    To copy to clipboard, switch view to plain text mode 

    then the internal widgets move more close fashion to the desired results, but still scroll bars frozen while moving and internals of the widgets are degraded during scrolling, see video recorded:

    "https://www.box.com/s/irv4qqgmxmewvydc8ual":https://www.box.com/s/irv4qqgmxmewvydc8ual

    The question is how to correct that, what widgets properties to set to what value ? How to code the scrolling ?
    Thanks.
    Last edited by freely; 11th January 2013 at 12:59.

  2. The following user says thank you to freely for this useful post:


Similar Threads

  1. QGraphicsView and Scrolling
    By validator in forum Qt Programming
    Replies: 5
    Last Post: 8th September 2017, 00:27
  2. QTreeView problem scrolling to end.
    By seneca in forum Qt Programming
    Replies: 7
    Last Post: 22nd December 2015, 12:08
  3. Replies: 3
    Last Post: 25th May 2010, 10:29
  4. Custom scrolling of QGraphicsView
    By hb in forum Qt Programming
    Replies: 0
    Last Post: 12th August 2008, 10:10
  5. QGraphicsView scrolling problem with 4.3.0
    By hb in forum Qt Programming
    Replies: 8
    Last Post: 30th August 2007, 22:18

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.