Questions tagged [qgridlayout]

A QGridLayout is a class from the Qt toolkit which lays out GUI widgets in a grid.

QGridLayout takes the space made available to it by its parent layout or widget, divides it up into rows and columns, and puts each widget it manages into the correct cell.

Each column and row has a minimum width/height and a stretch factor (which determines how much of the available space the column or row will get over and above its necessary minimum). It is also possible for widgets to span multiple rows and/or columns.

The official Qt documentation can be found here.

203 questions
38
votes
4 answers

Qt Layout, resize to minimum after widget size changes

Basically I've got a QGridLayout with a few widgets in it. The important ones are 2 labels, which I use for drawing images to the screen. Well, if the user wants, he can change the resolution of the incoming images, thus, forcing the Labels to…
Hafnernuss
  • 2,659
  • 2
  • 29
  • 41
22
votes
2 answers

How to arrange the items in QGridLayout as shown?

------------ ------ | | | 2 | | | | | | 1 | ------ | | ------ | | | 3 | ------------ ------ How to arrange the QGridLayout like above? I tried: QGridLayout *layout = new…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
14
votes
2 answers

Removing widgets from QGridLayout

I try to remove widgets from a specified row in a QGridLayout like this: void delete_grid_row(QGridLayout *layout, int row) { if (!layout || row < 0) return; for (int i = 0; i < layout->columnCount(); ++i) { QLayoutItem* item =…
maverik
  • 5,508
  • 3
  • 35
  • 55
13
votes
1 answer

How does setColumnStretch and setRowStretch works

I have an application built using PySide2 which uses setColumnStretch for column stretching and setRowStretch for row stretching. It works well and good, but i am unable to understand how it is working. I refer to the qt docs, but it doesn't helped…
Abhay Salvi
  • 890
  • 3
  • 15
  • 39
12
votes
3 answers

Qt QGridLayout automatically centers (moves) items to the middle.

I have a QHBoxLayout on my form with 3 layouts added to it. The second one has the items concerning my question. I have a QVBoxLayout on the second pane of the main layout (the QHBoxLayout). This QVBoxLayout has a QScrollArea added to it with…
Phil
  • 13,875
  • 21
  • 81
  • 126
10
votes
1 answer

A widget contained in more than one cell in a QGridLayout is not centered

The question sais it all. I have a 5 x 3 grid. It looks like this row 0: buttonA--buttonA--buttonA nothing buttonB--buttonB--buttonB row 1: empty row row 2: buttonC nothing buttonD nothing buttonE nothing buttonF In the…
Darkgaze
  • 2,280
  • 6
  • 36
  • 59
8
votes
2 answers

How does one fill a QGridLayout from top-left to right?

I would like to fill a QGridLayout with QWidgets. The QWidgets need to appear in a top-left to top-right fashion and proceed to fill the down downwards after each row is filled with QWidgets. An example of a similar and familiar GUI is how Apple…
Alex
  • 599
  • 1
  • 4
  • 16
8
votes
1 answer

QGridLayout different column width

I am trying to create a layout looking like this: _________ | | | |1 | 2 | |__|______| | 3 | 4 | |____|____| Basically, I want cell number 1 the first row to be thinner that cell 2, but cells number 3 and 4 on the second row should have…
hoan
  • 1,277
  • 3
  • 18
  • 32
7
votes
1 answer

PyQt: Is it possible to drag/drop QWidgets in a QGridLayout to rearrange them?

I am looking for a way to create a grid of graphs that can be dragged/dropped to rearrange the order. My first try was using QDockWidgets as they allow for drag/drop, however they were limited in a lot of other ways. Would it be possible to…
Frederik Petri
  • 451
  • 8
  • 24
7
votes
1 answer

QML Layouts: How to give weights to items in a row or column layout?

I'm trying to figure out a way to layout items proportionally by specifying a kind of weight for each item. For example the way Android does their layouts. The way I'm trying to achieve it is like so: import QtQuick 2.10 import QtQuick.Controls…
Tony Clifton
  • 467
  • 3
  • 10
7
votes
1 answer

How to set QPushButton size in QGridLayout in Qt

I am currently learning qt. And I am trying to build a small GUI program with 81 QPushButton on it. I want to set those buttons to 9 rows and 9 cols. The best way I can think to implement this layout is using QGridLayout. This is how that looks…
Theodore Tang
  • 831
  • 2
  • 21
  • 42
6
votes
3 answers

QGridLayout, 3 panes, not expanding properly

I'm trying to layout a window (all in code) with a QGridLayout. I can add widgets to the layout and they display in my window, but I can't figure out how to resize them properly. Here's what I'd…
jbrennan
  • 11,943
  • 14
  • 73
  • 115
6
votes
1 answer

How to fix the width/height to specific column/row in QGridLayout?

To this question I am referring to the example calculator.py from http://zetcode.com/gui/pyqt5/layout/ In the example the QGridLayout was used. I want to ask if it is possible to define the width/height to some specific columns/rows? Please see the…
Rt Rtt
  • 595
  • 2
  • 13
  • 33
5
votes
3 answers

QDockWidget with a QGridLayout - Widget within the Layout do not align to the top

I'm attempting to create a dockable toolbar (similar to what you use in Photoshop) that will hold a 2 x (n) grid of buttons. My idea is to use a QGridLayout parented to a blank QWidget, which is added to a QDockWidget, and add buttons to the…
dajaffe
  • 855
  • 13
  • 34
5
votes
2 answers

QT: Remove space between QLabel in QGridLayout

I Added some QLabels with different colors to A QGridLayout as Layout of a QWidget, now I have a spacing between each Qlabel to the next and I want to remove it. I tried to set the margin of the Labels to "0" and the Alignment of the GridLayout to…
dadod2
  • 515
  • 1
  • 6
  • 11
1
2 3
13 14