Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91366

Re: [QT] Scroll multiple lists with one scrollbar

From Laura Creighton <lac@openend.se>
Subject Re: [QT] Scroll multiple lists with one scrollbar
References <53f83314-12a6-4368-894f-13e756b5a888@googlegroups.com>
Date 2015-05-28 14:18 +0200
Newsgroups comp.lang.python
Message-ID <mailman.130.1432815493.5151.python-list@python.org> (permalink)

Show all headers | View raw


Looks like what you need to do is to 
connect verticalScrollBar().valueChanged (in one widget) to
verticalScrollBar().setValue in all of the others.

So is this code on the right track?  It uses lists, not labels, and
doesn't hide the scrollbars, but is this the behaviour you need (
and weren't getting)?  It should work for labels too..


from PyQt4 import QtGui, QtCore

class Window(QtGui.QWidget):
    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.listA = QtGui.QListWidget(self)
        self.listB = QtGui.QListWidget(self)
        self.listC = QtGui.QListWidget(self)

        widgets=[self.listA, self.listB, self.listC]
        layout = QtGui.QHBoxLayout(self)

        for w1 in widgets:
            layout.addWidget(w1)
            for index in range(100):
                w1.addItem('This is line number %d' % (index +1))
            for w2 in widgets:
                if w1 != w2:
                    w1.verticalScrollBar().valueChanged.connect(w2.verticalScrollBar().setValue)
            
if __name__ == '__main__':

    import sys
    app = QtGui.QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[QT] Scroll multiple lists with one scrollbar Alexis Dubois <alex@duboaa.net> - 2015-05-28 02:50 -0700
  Re: [QT] Scroll multiple lists with one scrollbar Laura Creighton <lac@openend.se> - 2015-05-28 12:11 +0200
    Re: [QT] Scroll multiple lists with one scrollbar Alexis Dubois <alex@duboaa.net> - 2015-05-28 03:44 -0700
      Re: [QT] Scroll multiple lists with one scrollbar Laura Creighton <lac@openend.se> - 2015-05-28 12:54 +0200
  Re: [QT] Scroll multiple lists with one scrollbar Laura Creighton <lac@openend.se> - 2015-05-28 14:18 +0200
    Re: [QT] Scroll multiple lists with one scrollbar Alexis Dubois <alex@duboaa.net> - 2015-05-28 05:53 -0700
      Re: [QT] Scroll multiple lists with one scrollbar Laura Creighton <lac@openend.se> - 2015-05-28 17:05 +0200
  Re: [QT] Scroll multiple lists with one scrollbar Peter Otten <__peter__@web.de> - 2015-05-28 14:35 +0200
    Re: [QT] Scroll multiple lists with one scrollbar Alexis Dubois <alex@duboaa.net> - 2015-05-28 05:54 -0700

csiph-web