Question

The problem seems simple but I don't solved it in 2 hours.I Have this Layout:

QGridLayout* view = new QGridLayout(this);
view->setSpacing(15);
view->addWidget(x0,2,1);
view->addWidget(x1,1,1);
view->addWidget(keyboard,2,0);
view->addWidget(x2,1,0);
view->addWidget(draw,0,0,0,1);
resize ( 650,650);
this->setLayout(view);

I need that "draw" (the graphical part of the project),occupies the top end of the project (row 0, column 0 to column 1).

The problem is that whatever value I put in the constructor:

void QGridLayout :: addWidget (QWidget * widget, int fromRow, fromColumn int, int rowSpan, columnSpan int, Qt :: Alignment alignment = 0) 

All other Widgets are like blocked and I can not interact when my program is running.

With classic constructor

void QGridLayout :: addWidget (QWidget * widget, int row, int column, Qt :: Alignment alignment = 0) 

No problems, but the Widget "draw" is not where I want to (only 1 column instead of 2).

Anyone know where I'm doing it wrong?

PS: Widgets have no layout settings (apart a numeric keypad to fix the minimum height for the keys).

Was it helpful?

Solution

row span is literal, not index like variable. If you want to put 2 column/row span you must put value 2 in span params. So you need to modify this view->addWidget(draw,0,0,0,1); to view->addWidget(draw,0,0,1,2);. Row/col span of 1 will include only "from row/column" not "from row/column + 1"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top