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
2
votes
2 answers

Qlabel in front of a QGridLayout

I am trying to make a QLabel appear over a QGridLayout, but I cannot figure how to do it. This is a sample code: from PyQt5.QtWidgets import QWidget, QApplication, QGridLayout, QFrame, QLabel import sys class Foo(QWidget): def…
Víctor Martínez
  • 854
  • 2
  • 11
  • 29
2
votes
1 answer

QGridLayout with PlotWidget-pyqtgraph

I have 3 PlotWidget (from the pyqtgraph library), obj1, obj2 and obj3, which I try to insert in a QGridLayout. I want to display all three objects in a single row, but obj1 must be twice as large as obj2 and obj3. Thus I…
floflo29
  • 2,261
  • 2
  • 22
  • 45
2
votes
1 answer

how can I make QGridLayout() resizable in both horizontal and vertical directions?

I can successfully get the layout correctly with the code below, how can I resize this QGridLayout horizontally and vertically? self._s_q0= QLabel(u'what is your favorite color?') self._e_q0 = QLineEdit(self) self._e_q0.setText("yellow is the best…
Jack
  • 27
  • 5
2
votes
1 answer

pyqt: update QGridLayout correctly when deleting all items and adding new

I have a QGridLayout with 3 columns, created like this self.my_grid = QGridLayout() self.my_grid.setColumnStretch(2, 0) After filling the grid with 10 items, it looks as expected like this: X X X X X X X X X X At certain events the grid items…
user3729611
  • 385
  • 3
  • 9
2
votes
3 answers

QGridLayout 3x3 grid resize widgets

I have 9 QWidgets. Sometimes they are invisible. They are all in a 3x3 grid. [0][3][6] [1][4][7] [2][5][8] Now if for example widget 3 is made invisible, other widgets should should resize: [ 0 ][ 6 ] [ 1 ][ 4 ][ 7 ] [ 2 ][ 5 ][ 8…
fonZ
  • 2,428
  • 4
  • 21
  • 40
2
votes
1 answer

Square custom QWidgets inside QGridLayout inside QScrollArea

I'm trying to lay out a grid of square custom (subclassed) QWidgets inside a QGridLayout and QScrollArea. The way I want it to work is choosing the number of QGridLayout columns and creating squares of the correct sizes. What I've tried doing…
blashyrk
  • 107
  • 1
  • 6
2
votes
1 answer

QPushButton 100% height of QGridLayout's cell

qroupBoxButtons = new QGroupBox(); QGridLayout *layout = new QGridLayout; pushButtonPlus = new QPushButton( tr( "+" ) ); layout -> addWidget( pushButtonPlus, 1, 1 ); /* add another elements to layout */ layout -> setColumnStretch( 1, 25…
ostapische
  • 1,572
  • 2
  • 12
  • 26
2
votes
1 answer

QToolButton with text: Overwrite minimal height to minic regular button height

I am displaying QToolButtons with icon plus text (Qt::ToolButtonTextBesideIcon) outside of a tool bar. Each button has a QAction associated with it which determines the used icon and the displayed text. All those buttons are placed inside a…
Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53
2
votes
1 answer

Accessing widgets which are members of a GridLayout

I am a newbie Qt Developer (almost a month) and I searched the net for a solution on my problem but I found nothing. Maybe, I didn't know how or what to ask about it. So, I will present the problem that haunts me a couple of days now. I create a…
nikpelgr
  • 23
  • 5
2
votes
1 answer

QGridLayout with colspan and rowspan

I can't create a QGridLayout like this one. I tried but I failed QGridLayout *layout = new…
splunk
  • 6,435
  • 17
  • 58
  • 105
2
votes
0 answers

How is it right to specify the percentage of columns GridLayout in Qt?

I am writing an application for kiosk PyQt4. I need to place widgets inside the window. I need to clearly define the ratio of the two columns of QGridLayout (It is green in the image). It's decided by setting the first column…
ftp27
  • 885
  • 1
  • 12
  • 31
2
votes
0 answers

Area for detachable QDialogs within QGridLayout

I have a QMainWindow with a QGridLayout of various widgets that looks like the following: I will have various little input dialogs that come up at different times, and I want them to appear in certain cell of the layout (bright cyan area below…
norman
  • 5,128
  • 13
  • 44
  • 75
2
votes
1 answer

How to access widgets coordinates in QGridLayout

I am in the process of putting Qlabels in a QGridLayout to arrange them nicely in a class derived from QWidget. However, when I try to access the coordinates, it always returns (0,0) Here is my code : class brick : public QWidget { Q_OBJECT public: …
user3476114
  • 634
  • 1
  • 7
  • 17
2
votes
1 answer

Widgets not showing up on a Grid layout (PySide)

I have some code that displays a few widgets in the window. The widgets, however do not appear on the window: #!/usr/bin/python import sys from PySide import QtGui class Window(QtGui.QMainWindow): def __init__(self): …
Awalrod
  • 268
  • 1
  • 4
  • 14
2
votes
2 answers

rowspan of QGridLayout not working as expected

Here is how to draw a button that spans 2 columns: #include int main(int argv, char **args) { QApplication app(argv, args); QPushButton *foo = new QPushButton("foo"); QPushButton *bar = new QPushButton("bar"); QPushButton…
tshepang
  • 12,111
  • 21
  • 91
  • 136