"BumbleBee"
24th March 2011, 11:28
So,I'm making a Tic Tac Toe game and I'd like to put my buttons,like: 3 rows of 3 buttons.
So far I have this:
win = new QWidget;
btn[0] = new QPushButton(this);
btn[1] = new QPushButton(this);
btn[2] = new QPushButton(this);
btn[3] = new QPushButton(this);
btn[4] = new QPushButton(this);
btn[5] = new QPushButton(this);
btn[6] = new QPushButton(this);
btn[7] = new QPushButton(this);
btn[8] = new QPushButton(this);
hl1 = new QHBoxLayout;
hl2 = new QHBoxLayout;
hl3 = new QHBoxLayout;
vl1 = new QVBoxLayout;
hl1->addWidget(btn[0]);
hl1->addWidget(btn[1]);
hl1->addWidget(btn[2]);
hl2->addWidget(btn[3]);
hl2->addWidget(btn[4]);
hl2->addWidget(btn[5]);
hl3->addWidget(btn[6]);
hl3->addWidget(btn[7]);
hl3->addWidget(btn[8]);
vl1->addLayout(hl1);
vl1->addLayout(hl2);
vl1->addLayout(hl3);
win->setLayout(vl1);
TicTacToe::setCentralWidget(win);
But buttons here have the normal size..how can I make then be square?
Thank you.
So far I have this:
win = new QWidget;
btn[0] = new QPushButton(this);
btn[1] = new QPushButton(this);
btn[2] = new QPushButton(this);
btn[3] = new QPushButton(this);
btn[4] = new QPushButton(this);
btn[5] = new QPushButton(this);
btn[6] = new QPushButton(this);
btn[7] = new QPushButton(this);
btn[8] = new QPushButton(this);
hl1 = new QHBoxLayout;
hl2 = new QHBoxLayout;
hl3 = new QHBoxLayout;
vl1 = new QVBoxLayout;
hl1->addWidget(btn[0]);
hl1->addWidget(btn[1]);
hl1->addWidget(btn[2]);
hl2->addWidget(btn[3]);
hl2->addWidget(btn[4]);
hl2->addWidget(btn[5]);
hl3->addWidget(btn[6]);
hl3->addWidget(btn[7]);
hl3->addWidget(btn[8]);
vl1->addLayout(hl1);
vl1->addLayout(hl2);
vl1->addLayout(hl3);
win->setLayout(vl1);
TicTacToe::setCentralWidget(win);
But buttons here have the normal size..how can I make then be square?
Thank you.