Here is how to draw a button that spans 2 columns:
#include <QtGui>
int main(int argv, char **args)
{
QApplication app(argv, args);
QPushButton *foo = new QPushButton("foo");
QPushButton *bar = new QPushButton("bar");
QPushButton *baz = new QPushButton("baz");
QGridLayout *layout = new QGridLayout();
layout->addWidget(foo, 0, 0);
layout->addWidget(bar, 0, 1);
layout->addWidget(baz, 1, 0, 1, 2); // span 2 columns
QWidget window;
window.setLayout(layout);
window.setWindowTitle("test");
window.show();
return app.exec();
}
Running the code gives me:
If I change the layout in order to get a button, baz
, that spans 2 rows I fail:
layout->addWidget(foo, 0, 0);
layout->addWidget(bar, 1, 0);
layout->addWidget(baz, 0, 1, 2, 1); // (try to) span 2 rows
Here is what I get: