Answer the question
In order to leave comments, you need to log in
How to position QScrollBar on another widget?
Hello. I need to position the QScrollBar widget on another widget, but have the scrollbar attached to another widget.
In the case of QTextEdit, the QScrollBar is placed in the text field when using .setWidget, which is not what I want.
Is it possible to put a QScrollBar on one widget (eg QLabel) but bind it to another (eg QTextEdit) and how to implement it?
Answer the question
In order to leave comments, you need to log in
Create a QScrollBar widget, and then QTextEdit.setVerticalScrollBar(custom scroll) or setHorizontalScrollBar
import sys
from PySide2.QtWidgets import QApplication, QMainWindow, QWidget, QHBoxLayout, QTextEdit, QScrollBar
class Main(QMainWindow):
def __init__(self):
super(Main, self).__init__()
centralWidget = QWidget(self)
self.setCentralWidget(centralWidget)
# добавляем компонощик
self.h_grid = QHBoxLayout(centralWidget)
self.customScroll = QScrollBar()
# добаляем QtextEdit
self.textEdit = QTextEdit()
# задаем для него скролл
self.textEdit.setHorizontalScrollBar(self.customScroll)
# убираем полосу, отведенную под скролл
self.textEdit.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.h_grid.addWidget(self.textEdit)
self.h_grid.addWidget(self.customScroll)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Main()
ex.show()
sys.exit(app.exec_())
It should be understood that you are trying to update the data not only by the limit but also by the offset, and MySQL cannot do this (@romy4 gave you a link to the documentation)
If you want to use the limit and offset, then you need to first make a selection and only then update, for example :
UPDATE `table` SET `fourth`=8 WHERE id in (SELECT id FROM `table` LIMIT 1,3)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question