Answer the question
In order to leave comments, you need to log in
The scrollbar returns to its default PyQt5 state. What's wrong?
I am writing an interface for a text editor, where I synchronize two scrollbars with the following script:
self.list_of_tables = [self.lines,self.text]
def move_other_scrollbars(idx,bar):
scrollbars = {tbl.verticalScrollBar() for tbl in self.list_of_tables}
scrollbars.remove(bar)
for bar in scrollbars:
print(idx)
bar.setValue(idx)
for tbl in self.list_of_tables:
scrollbar = tbl.verticalScrollBar()
scrollbar.valueChanged.connect(lambda idx,bar=scrollbar: move_other_scrollbars(idx, bar))
self.lines
is a QTextBrowser that cannot be changed, it displays lines, and self.text
is a QTextEdit, in which the text itself is edited. I hid the scrollbar from the rows, but that's not the problem. All this moves synchronously, but as soon as you start selecting from the bottom up, something is updated, apparently, and the scrollbar returns to the 0th state. I even print(idx)
decided to display the values, and this is what I got: bar.setValue(idx)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question