I would like to create a Qwidget with a large number of square QPushButtons. I would like those buttons to be organised into a mosaic layout. Whenever the window is resized, the mosaic widget should be resized and the buttons re-ordered accordingly to fill in the width. Buttons that cannot fit within the area, can be viewed by scrolling the widget vertically.
Is there a Qt4 Layout that allows me to do this easily? What is the best / easiest way to achieve this? Thanks.
You could use the flow layout (from Qt examples) inside a resizable QScrollArea.
Use a QGridLayout in a QScrollArea.
Related
I'm trying to build a screen where there is a fixed widget at the top of the screen and another widget which is fixed to the bottom of the screen and in between is a scrollable widget.
I want to have the content inside the scrollable widget scroll underneath the two fixed widgets (both with a transparent blur), to indicate that there is more content underneath.
Here is an image of what I am trying to do.
I am currently using a Stack for this, however I am having to manually adjust the padding in the SingleChildScrollView to offset for the top and bottom widgets, but I would like to have this be much more flexible and have the widgets be any size and not have to update the padding.
I've found other examples where the bottom widget is part of the scrollable content but that isn't quite what I am looking for.
Does anyone know of a way to do this, without having to manually provide the padding?
I have a window in mono gtk#, which has lot of VBoxes & HBoxes. These boxes contain some buttons, labels, and some other widgets also. Now I need to make this window alone to transparent.
I created one drawingArea by referring zetcode page.
But inside this drawing area I'm not able to do the arrangements of my widgets, one Move function is available, but it is not much use for me. So how do I do widget arrangement neatly inside a drawingArea?
So, I am trying to make a video game in Tkinter (no, I don't want to use PyGame), but I have ran into a bit of a problem.
I have realized that sometimes you may want to have two widgets overlap (e.g. sprite on top of background) but have the contents of both widgets to be visible. For example, I might have a sprite with transparent sections.
How do I set the "background" option of a widget so that there is no visible background?
Note: "you can't do this" answers are acceptable.
This is not really posible in Tkinter. But you can set the transparency of the whole window with root.attributes('-alpha', 0.5)
For windows, you can do root.attributes("-transparentcolor", "red"), but again it will be applied to the whole window, not just the single widget.
I have a QHBoxLayout, and it has 2 QVBoxLayouts on it one near the other.
Each layout has widgets, and I wonder how to make this layout resizable (the user can change the width) ?
Use a QSplitter. Create a couple of top-level container widgets for your vbox layouts, and then use the splitter's addWidget method to add the widgets to the splitter. The splitter's orientation is horizontal by default, so the vboxes will appear side by side.
I'm new to Qt Designer, and I am working on a main window where I want to have two list widgets off to the right, laid out in a vertical splitter, and then a larger text browser widget to the left, which is then itself in a splitter with the list widgets. So the relative sizes of the list widgets can be resized vertically, and the horizontal space between the text browser and the other two widgets can also be resized.
I tried first laying out the two widgets on the right in a vertical splitter, and then selecting the layout, like so:
The problem is, now that the two list widgets are in the splitter layout, I can't then add that layout to any other larger layouts. All the options appear grayed out. If I just do a standard horizontal or vertical layout, it is possible to then make larger layouts out of smaller ones. So how is this to be done when using splitter layouts? Thanks!
Look's like you are selecting two ListWidgets instead splitter. To combine layouts you need to select one splitter which contains ListWidgets and then TextBrowser. In this case Lay Out Horizontaly in splitter will be available.
Here video demonstration (1.25 MB)