I want to auto resize the above picture at the size shown below when user resize the main window.
Is there any function to do this in pyqt4?
I was searching for an answer to this problem... but i can't find something related.
I've tried to set fixed minimum size but this doesn't work.
How to auto resize a window in pyqt4 (python)?
pictures is got in qtdesigner.
If you are using the QtDesigner, then its really easy. Have a look at layouts like vertical layout, horizontal layout
Follow step:
1. Add layout to your main window.
2. Right click main window and click 'layout vertically' as you want button below
the text area
3. Then add(drag-n-drop) your text area inside vertical area.
4. Add button and what not....
5. Have a look at 'http://doc.qt.io/qt-4.8/designer-layouts.html' google for
properties of layout like alignment of element. size, orientation.
Related
I am trying to make a GUI that is very similar to Spotify using PyQT
I've already designed the main window and I am struggling with applying the design to QT Creator.
This is what I want it to look like
But I'm trying to use Layouts in order to organize every widget.
For example
Image of the main window, split into 3 parts
like in the sketch I've made the software will be split into 3 parts, left bar, mid which is where the explore title is and right bar.
The problem I have is that I can't control the layouts size and the size of what's below them for example in the sketch the mid bar is wider than the right bar and the right bar is wider than the left bar but in the QTCreator I've no idea how to change the width and height of objects inside Layouts.
The first option (which I personally prefer) is to fill your layout with it's contents first (buttons, labels, etc.). This will already start to scale your layout, if there are more buttons in the middle bar than on the other bars. If your layout still isn't what you want it to be, you can use Spacers. They can push and pull puttons and position the in relation to other parts of the layout, as well as to the layout itself. The scaling will be adjusted automatically according to the spacers position.
This option has the advantage, that your application will be correctly scaled and not completely chaotic when it is run on a device with a display aspect ratio which is not the same as the one of the machine your developing it on.
There is, however, also a minimumSize and maximumSize attribute to the layouts, which provide a much more straightforward possibility, but sometimes cause your layouts to become very weird when adding or removing a button, or changing the text of a label. More on this option can be found in the Qt docs:
https://doc.qt.io/qt-5/qlayout.html
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 make a list of custom widget vertically aligned, where I dynamically add the custom widget inside a scroll Area.
If I click on "add image", a custom widget is added to the scroll area with vertical layout.
like this :
Note that I didn't succeed to make the scroll Area expand as I add widget inside, I had to put a big minimum height to make a scrollbar appear.
The second issue is, when i add like this my widget they are spaced to much, and not added under each other. To prevent this I tried to add a vertical spacer. However, with the vertical spacer, the widget added by clicking on "add image" does not appear anymore (I use insertWidget(Vlayout.count()-1, mycustomwidget)
I organised everything like this :
the pushbutton is an example, I add my custom widget here.
Why the scroll Area doesn't expand as I had widget ? I tried :
self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.scroll.setWidgetResizable(True)
Why, when I had a spacer, the widget does not appear anymore ?
I am struggling on making a Pixmap button, since there was no other option (That i knew) i tried using QIcon.
The picture that i wanted as button, was not fully square, i wanted to only show the pixmap, but with it still having a button function (Signals connecting to slots, etc.).
When i tried to make the Icons size equal to button, Icon would go up and it wouldn't fit in at all, and button would show outside of icon.
So the Question is:
How can i make icon greater than a QPushButton? so only icon would show and it would still have icon functions.
If this is over Icon borders, then is it any other way making Pixmap buttons?
You can simply use css to achieve that with the background-image property like this and also set the border to 0
btn.setStyleSheet("background-image: url('image.jpg'); border: none;")
I use PySide. Maybe the codes are similar
btn = QPushButton('')
btn.setIcon(QPixmap(image path))
# adjust width and height to fit the size of button.
btn.setIconSize(QSize(width, height))
# set zero border.
btn.setStyleSheet('QPushButton{border: 0px solid;}')
I am drawing inside a wx.Window using a PaintDC. I am drawing circles and stuff like that into that window. Problem is, sometimes the circles go outside the scope of the window. I want a scrollbar to automatically appear whenever the drawing gets too big. What do I do?
Use a wx.ScrolledWindow and set the size of the window as soon as your 'drawing go outside' the window with
SetVirtualSize(width,height)
If this size is bigger than the client size, then wx will show scrollbars. When drawing in the window make sure to use CalcUnscrolledPosition and CalcScrolledPosition
Here you can find some more information.