Introduced empty button grid

main
Isabell Pflug 1 year ago
parent dbb1bc84ff
commit 8a381d011b

@ -3,6 +3,12 @@
extern std::unique_ptr<QSettings> settings; extern std::unique_ptr<QSettings> settings;
// event functions
void MainWindow::buttonPressed(QPushButton *button) {
QString text = "owo";
button->setText(text);
}
// initialisation functions // initialisation functions
void MainWindow::initialiseGameGrid() { void MainWindow::initialiseGameGrid() {
qDebug() << "Number of rows: " << n_rows; qDebug() << "Number of rows: " << n_rows;
@ -11,6 +17,21 @@ void MainWindow::initialiseGameGrid() {
for (long long i = 0; i < colors.size(); i++) { for (long long i = 0; i < colors.size(); i++) {
qDebug() << colors.value(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() { void MainWindow::initialiseWindow() {

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

Loading…
Cancel
Save