Answer the question
In order to leave comments, you need to log in
How to add your widget in PyQt 5?
It is necessary to make a tape (as in VK). I decided to make the main widget and the widget for the post:
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
import sys
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
box = QVBoxLayout(self)
self.setLayout(box)
self.setFixedSize(500, 600)
self.move(300, 40)
scroll = QScrollArea(self)
box.addWidget(scroll)
scrollContent = QWidget(scroll)
scrollLayout = QVBoxLayout(scrollContent)
scrollContent.setLayout(scrollLayout)
for post in range(0, 100):
scrollLayout.addWidget(Post())
scroll.setWidget(scrollContent)
self.show()
class Post(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setWindowTitle('Post')
self.resize(100, 100)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
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