PySide window does not resize to fit screen

Chris Warrick kwpolska at gmail.com
Thu Oct 1 11:07:09 EDT 2015


On 1 October 2015 at 15:44, Hedieh Ebrahimi <hemla21 at gmail.com> wrote:
> Dear all,
>
> I am using Pyside to create a user interface for my app.
> The app works fine on my computer with big screen, but when I take it to my laptop with smaller screen size, it does not resize to match the screen size.
>
> How can I make my main widget get some information about the screen size and resize automatically?
>
> Thanks in Advance for your answers.
> --
> https://mail.python.org/mailman/listinfo/python-list

The correct way to do this is to lay your application out using a
layout.  The available layouts are:

* QHBoxLayout
* QVBoxLayout
* QGridLayout
* QFormLayout

The exact layout to use depends on your needs.

What are you using to create your Qt code? Are you using Qt Designer
or are you writing the code by hand?  If you are using Qt Designer,
use the “Lay Out…” buttons in the Form menu or on the tool bar.  If
you are writing Qt code by hand, it looks roughly like this (for a
VBox; Grid and Form are more complicated as they involve positioning):

lay = QtGui.QVBoxLayout(self)  # your central widget, dialog, main
window — whichever one exists
btn = QtGui.QButton("Hello", lay)
lay.addWidget(btn)

Please check with Qt documentation for more details

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16



More information about the Python-list mailing list