So Qt Designer has this feature where you can resize the window you're working on. And that's fine and dandy, but every now and then, I accidentally drag it, and the window gets larger or smaller than I wanted it to be. The undo action doesn't undo the resizing, so that's a bummer. Also setting max and min sizes for the central widget doesn't do anything to fix this issue.
Is there a way I can have the window size locked?
Here's a demo:
Use QWidget::setFixedSize(w, h) for explicitly set width and height or QLayout::setSizeConstraint(QLayout::SetFixedSize) if you want the fixed size to be determined automatically based on content.
Related
I have written a guizero code that creates a new window with different amounts of information on it depending on what is selected. I was just wondering if there is a function to resize the window to fit all of the information. I am currently just making the window big enough to fit the largest amount of information but I would rather have it so it resizes it automatically.
And also is there a simple function so that if the window size is changed all of the widgets inside of it change size as well?
I think is not possible to automaticly resize the window but you can count the number of lines and resize the window.
numLines*defaultHeightByLine + height of the other elements
I want to test the appearance of a window on a smaller monitor than the one I'm using on the development machine.
I tried with set_geometry_hints() (setting minimum and maximum width and height), set_resizable(False), set_default_size(), and set_size_request(). However every time the window is bigger, because child widgets request a bigger size.
I noticed on a smaller monitor with a resolution smaller than the request size, the widgets are truncated. I have to be sure this doesn't happen refactoring the GUI layout, so I want to simulate on my monitor.
How can I make the window smaller without truncating widgets?
Setting the window size request should be sufficient. If your UI makes the window larger that is the same as your widgets becoming truncated on a smaller monitor.
To prevent this you'll need to put widgets that grows your UI inside scrollable windows. Watch out for labels. You will need to get them to wrap properly.
Is it possible that when a Tkinter window is made bigger or larger, everyhting in the window is scaled?
So all the proportions stay the same but their sizes vary.
Now when the window is resized all the buttons etc stay the same so I disabled resize because there is no point, it just looks bad.
No, it is likely not possible, depending on what you mean by "everything" and what you mean by "scaled". Any widget can be made to stretch to fill its allotted space. Text widgets and canvas widgets, for example, scale nicely. A button or label will fill the space it's in, but the text inside the widget won't change (that is also true of text and canvas widgets).
It's possible to organize your GUI so that when the window resizes, everything remains in its proper place at its original size. Having buttons that automatically scale is not something most people would expect. Disabling resizing usually results in a poor user experience -- users should have the ability to make a window larger or smaller.
When a User opens a particular tab inside the QMainWindow of my PyQt4 driven GUI,
the window needs to be automatically resized so that the contents of this particular tab will fit.
As you know, when using Qwidget.resize(), the Window (by default on PC) is instantly resized.
This isn't easy on the eyes and would probably surprise / confuse the User.
Is it possible to have the window smoothly transition into the new window size?
(An animation in essence)
(For instance, a really horrible method would be to continuously call resize, each time slightly increasing the window size to elude to a transition)
The window size is not adjustable to the User, so when the window exands and shrinks to and from the different sizes, I know their exact dimensions. It is also known to me that all my Users run Windows 7 (Since my users are school mates in a tablet program).
Does anybody know if this is possible with PyQt4, and how to achieve it?
(Qt Kinetic sounded relevant to me, but it's proven difficult to search for the appropriate information)
Thanks! x 100
Specs:
- PyQt4
- Python 2.7
- Windows 7
There is QPropertyAnimation which can be used to animate QObject properties, including the size of your window.
I'm not sure if it will work well performance wise, since it will call resize() perpetually, as you say, but it seems like that is what you want.
What you could maybe do is to resize the window, but somehow disable painting (i.e. override paint()) during that animation, so that only the frame is smoothly resized (should be ok) and the interior is not redrawn until the target size has been reached.
I'm working with several widgets but the solution just won't come out. What I have is a series of buttons in series of QHBoxLayouts. Some buttons are hidden by default, but they will appear when needed. To solve space issues, all buttons have a minimum and maximum size so they always look well packed. Also I have a QTextEdit, visible by default, which is in a QVBoxLayout with the QHBoxLayout that hold the buttons
So the problem is this: When I hide the QTextEdit and show the other buttons, the window won't resize.
After searching I found that using self.ui.layout().setSizeConstraint(QtGui.QLayout.SetFixedSize) will do the trick, but the problem is that it takes the maximum size from all widgets, therefore I end a huge window. Doing self.ui.layout().setSizeConstraint(QtGui.QLayout.SetMinAndMaxSize) won't resize the window
I already tried using self.ui.resize(0,0), and when doing a self.ui.layout().update() I got False (which I find odd, http://doc.trolltech.com/4.6/qlayout.html#activate), and also tried to override sizeHint() but it keeps using the max size for all widgets.
Is there a way to resize the window and while taking care of the min and max size of a widget?
Thanks in advance
The answer was quite lame... Just needed to change the QVBoxLayout for a QGridLayout and use self.ui.layout().setSizeConstraint(QtGui.QLayout.SetFixedSize)