I am trying out QT to rework a WPF project. I want to use a QGridLayout for laying out buttons, each 64x64 px in dimension. However, the grid does not seem to respect these dimensions, I'm sure 64x64 is not that small. Also, there is a huge gap between the elements. How could I more tightly pack these buttons and make them all be uniformally 64 by 64 px? Preferrably even limit column and row count to 4 and window_height/64
Code:
#include "productbuttongrid.h"
#include <QPushButton>
ProductButtonGrid::ProductButtonGrid(QWidget *parent): QGridLayout(parent)
{
QPushButton *button = new QPushButton("Toode", parent);
button->setFixedSize(64,64);
QPushButton *button2 = new QPushButton("Toode2", parent);
button2->setFixedSize(64,64);
QPushButton *button3 = new QPushButton("Toode2", parent);
button3->setFixedSize(64,64);
QPushButton *button4 = new QPushButton("Toode2", parent);
button4->setFixedSize(64,64);
QPushButton *button5 = new QPushButton("Toode2", parent);
button5->setFixedSize(64,64);
this->addWidget(button,0,0);
this->addWidget(button2,0,1);
this->addWidget(button3,0,2);
this->addWidget(button4,0,3);
this->addWidget(button5,1,0);
}
And what this outputs, instead of the 64x64 buttons: They also seem a bit too small to be 64x64

button2->setFixedSize(64,64);four times. Probably not what you intended.