maelorn
maelorn

Reputation: 132

QGridLayout with different size of cells

I'm trying to set a QGridLayout with four widget as in the image below: Goal

however what I've managed with QGridLayout as of now is: Current situation

I don't see how I can set the size of the row different for column 0 and 1. Maybe QGridLayout is not the right way of doing it but I don't know of any other widget that would do the trick. Does anyone have any idea how to achieve this?

Upvotes: 4

Views: 4185

Answers (2)

MultiVAC
MultiVAC

Reputation: 354

I don't think grids are the way to go here indeed...

You could try making a horizontal layout of 2 QFrames, in which you set a vertical layout each with the two widgets of that "column"

Upvotes: 3

vahancho
vahancho

Reputation: 21220

I would use vertical and horizontal layouts instead of the grid layout. So you need two vertical layouts and horizontal one:

// Left side
QLabel *lbl1 = new QLabel(this);
QTableWidget *t = new QTableWidget(this);
QVBoxLayout *vl1 = new QVBoxLayout;
vl1->addWidget(lbl1);
vl1->addWidget(t);

// Right side
// QImage is not a widget, so it should be a label with image
QLabel *lbl2 = new QLabel(this);
QCustomPlot *pl = new QCustomPlot(this);
QVBoxLayout *vl2 = new QVBoxLayout;
vl2->addWidget(lbl2);
vl2->addWidget(pl);

// Create and set the main layout
QHBoxLayout mainLayout = new QHBoxLayout(this);
mainLayout->addLayout(vl1);
mainLayout->addLayout(vl2);

Upvotes: 5

Related Questions