Results 1 to 4 of 4

Thread: scrolling in QTableWidget

  1. #1
    Join Date
    Jul 2007
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: scrolling in QTableWidget

    Provided that dimensions are same, it should be as simple as connecting scrollbars' valueChanged(int) signals to setValue(int) slots:
    Qt Code:
    1. // establish connections in both directions
    2. connect(table1->horizontalScrollBar(), SIGNAL(valueChanged(int)), table2->horizontalScrollBar(), SLOT(setValue(int)));
    3. connect(table2->horizontalScrollBar(), SIGNAL(valueChanged(int)), table1->horizontalScrollBar(), SLOT(setValue(int)));
    4. // ...and the same for vertical scroll bar
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Jul 2007
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: scrolling in QTableWidget

    Perhaps a missing #include <QScrollBar> ?
    J-P Nurmi

  5. The following 2 users say thank you to jpn for this useful post:

    SiL3NC3 (9th January 2013), Ursa (11th July 2007)

Similar Threads

  1. QGraphicsView scrolling problem with 4.3.0
    By hb in forum Qt Programming
    Replies: 8
    Last Post: 30th August 2007, 23:18
  2. QTableWidget (resizing rows, turning off selection, etc.)
    By kiss-o-matic in forum Qt Programming
    Replies: 6
    Last Post: 11th January 2007, 02:57
  3. QTableWidget issues
    By Djony in forum Qt Programming
    Replies: 42
    Last Post: 20th December 2006, 00:27
  4. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 19:46
  5. Replies: 6
    Last Post: 5th March 2006, 22:05

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.