Introduced empty button grid

main
Isabell Pflug 1 year ago
parent dbb1bc84ff
commit 8a381d011b

@ -3,6 +3,12 @@
extern std::unique_ptr<QSettings> settings;
// event functions
void MainWindow::buttonPressed(QPushButton *button) {
QString text = "owo";
button->setText(text);
}
// initialisation functions
void MainWindow::initialiseGameGrid() {
qDebug() << "Number of rows: " << n_rows;
@ -11,6 +17,21 @@ void MainWindow::initialiseGameGrid() {
for (long long i = 0; i < colors.size(); i++) {
qDebug() << colors.value(i);
}
for(int i = 0; i < n_columns; i++)
{
for(int j = 0; j < n_rows; j++)
{
QPushButton * button = new QPushButton(this);
ui->gameGridLayout->addWidget(button, j, i);
// Set size text etc. for each button
connect(button, &QPushButton::clicked, [=](){
buttonPressed(button);
});
}
}
}
void MainWindow::initialiseWindow() {

@ -6,6 +6,7 @@
#include <QDebug>
#include <QMainWindow>
#include <QPushButton>
#include <QSettings>
QT_BEGIN_NAMESPACE
@ -24,6 +25,9 @@ public:
void initialiseWindow();
void initialiseMenuBar();
// events
void buttonPressed(QPushButton *button);
private:
Ui::MainWindow *ui;
const int n_rows;

Loading…
Cancel
Save