Python Forum
[PyQt] QGridLayout, QProgressBar bar fills widgets shrink
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] QGridLayout, QProgressBar bar fills widgets shrink
#4
I don't see any problem with your original code. I just added the main window and frame, and some code to change the progress bar when you type in the QEditText widget. I don't see any lahout changes.
from PySide6.QtWidgets import QApplication, QMainWindow, QFrame, QLineEdit, QProgressBar, QLabel, QGridLayout, QTextEdit
from PySide6.QtCore import QTimer

class Window(QMainWindow):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        frame = QFrame()
        self.setCentralWidget(frame)
        layout = QGridLayout(frame)
        header = ['To:', 'CC:', 'BCC:', 'Subject:']
        edits = [QLineEdit(), QLineEdit(), QLineEdit(), QLineEdit()]
        for i, (lab, lin) in enumerate(zip(header, edits)):
            layout.addWidget(QLabel(lab), i, 0)
            layout.addWidget(lin, i, 1, 1, 5)

        self.edit = QTextEdit()
        self.prog = QProgressBar()
        layout.addWidget(self.edit, 4, 0, 1, 6)
        layout.addWidget(self.prog, 5, 1)

        timer = QTimer(self)
        timer.timeout.connect(self.update_progress)
        timer.start(100)

    def update_progress(self):
        self.prog.setValue(len(self.edit.toPlainText()))


app = QApplication()
window = Window()
window.show()
app.exec()
Reply


Messages In This Thread
RE: QGridLayout, QProgressBar bar fills widgets shrink - by deanhystad - Nov-21-2022, 09:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] QGridLayout and stretching widgets when maximized malonn 1 2,097 Oct-05-2022, 09:58 AM
Last Post: malonn

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020