Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created October 31, 2014 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ynonp/c7a48a85c2d102250599 to your computer and use it in GitHub Desktop.
Save ynonp/c7a48a85c2d102250599 to your computer and use it in GitHub Desktop.
#include "mainwindow.h"
#include <QApplication>
#include <QtWidgets>
void createFirstRow(QVBoxLayout *top)
{
QGroupBox *box = new QGroupBox();
QPushButton *b1 = new QPushButton("One", box);
QPushButton *b2 = new QPushButton("Two", box);
QPushButton *b3 = new QPushButton("Three", box);
QHBoxLayout *layout = new QHBoxLayout(box);
layout->addWidget(b1);
layout->addWidget(b2);
layout->addWidget(b3);
top->addWidget(box);
}
void createSecondRow(QVBoxLayout *top)
{
QGroupBox *box = new QGroupBox();
QPushButton *b1 = new QPushButton("One", box);
QPushButton *b2 = new QPushButton("Two", box);
QPushButton *b3 = new QPushButton("Three", box);
QHBoxLayout *layout = new QHBoxLayout(box);
layout->addWidget(b1);
layout->addWidget(b2);
layout->addWidget(b3);
top->addWidget(box);
}
void createThirdRow(QVBoxLayout *top)
{
QGroupBox *box = new QGroupBox();
QPushButton *b1 = new QPushButton("One", box);
QPushButton *b2 = new QPushButton("Two", box);
QPushButton *b3 = new QPushButton("Three", box);
QHBoxLayout *layout = new QHBoxLayout(box);
layout->addWidget(b1);
layout->addWidget(b2);
layout->addWidget(b3);
top->addWidget(box);
}
void createFourthRow(QVBoxLayout *top)
{
QGroupBox *box = new QGroupBox();
QPushButton *b1 = new QPushButton("One", box);
QPushButton *b2 = new QPushButton("Two", box);
QPushButton *b3 = new QPushButton("Three", box);
QHBoxLayout *layout = new QHBoxLayout(box);
layout->addWidget(b1);
layout->addWidget(b2);
layout->addWidget(b3);
top->addWidget(box);
}
void createFifthRow(QVBoxLayout *top)
{
QGroupBox *box = new QGroupBox();
QPushButton *b1 = new QPushButton("One", box);
QPushButton *b2 = new QPushButton("Two", box);
QPushButton *b3 = new QPushButton("Three", box);
QHBoxLayout *layout = new QHBoxLayout(box);
layout->addWidget(b1);
layout->addWidget(b2);
layout->addWidget(b3);
top->addWidget(box);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
QVBoxLayout *layout = new QVBoxLayout(&w);
createFirstRow(layout);
createSecondRow(layout);
createThirdRow(layout);
createFourthRow(layout);
createFifthRow(layout);
w.show();
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment