Re: VBoxLayout help.

Barry Scott <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <[email protected]>

> On 6 Mar 2020, at 07:25, Souvik Dutta Chowdhury <[email protected]> wrote:
> 
> I have a vbox layout which is my main layout. I have set a label to be the sole widget in my layout. I have not specified anything else except 
> self.vbox.addWidget(label)

> The problem is when the window is first run the label appears at the top most corner but then changes position to the middle of the page.

QVBoxLayout is documented here  https://doc.qt.io/qt-5/qvboxlayout.html <https://doc.qt.io/qt-5/qvboxlayout.html> says its a derived from
QBoxLayout  https://doc.qt.io/qt-5/qboxlayout.html <https://doc.qt.io/qt-5/qboxlayout.html> where the addWidget() call is documented.
addWidget has an alignment arg, I think that is what you are looking for.

> The change happens when I try to resize the window. Why is this happening and how to stop it?

The layouts cause the contained widgets to resize when the layout is resized. This is usually what you want.
If you really want to change the way resize works then override the resize (?) method on the widget.

> I even tried using a
> label.setGeometry(10, 10, 200, 200)

This is changed when the resize happens.

> The result is still the same.

Barry

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.