资源简介
用Qt写的单机版五子棋游戏的源代码,可供参考。
代码片段和文件信息
#include “dialog.h“
SelectDialog::SelectDialog(QWidget * parent Qt::WindowFlags f)
: QDialog(parent)
{
bAlgorithm = 0;
wAlgorithm = 0;
times = 100;
setFixedSize(250 150);
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
setWindowtitle(tr(“选择算法及对战次数“));
blackAlgorithm = new QComboBox;
blackAlgorithm->addItem(tr(“算法1(随机算法)“) 1);
blackAlgorithm->addItem(tr(“算法2(贪心算法)“) 2);
blackAlgorithm->addItem(tr(“算法3(改进的随机算法)“) 3);
connect(blackAlgorithm SIGNAL(currentIndexChanged(int))
this SLOT(bAlgorithmChanged(int)));
whiteAlgorithm = new QComboBox;
whiteAlgorithm->addItem(tr(“算法1(随机算法)“) 1);
whiteAlgorithm->addItem(tr(“算法2(贪心算法)“) 2);
whiteAlgorithm->addItem(tr(“算法3(改进的随机算法)“) 3);
connect(whiteAlgorithm SIGNAL(currentIndexChanged(int))
this SLOT(wAlgorithmChanged(int)));
label1 = new QLabel(tr(“黑棋的算法为:“) this);
QHBoxLayout * layout1 = new QHBoxLayout;
layout1->addWidget(label1);
layout1->addWidget(blackAlgorithm);
label2 = new QLabel(tr(“白棋的算法为:“) this);
QHBoxLayout * layout2 = new QHBoxLayout;
layout2->addWidget(label2);
layout2->addWidget(whiteAlgorithm);
label3 = new QLabel(tr(“对战的次数为:“) this);
currentTimesSlider = new QSpinBox(this);
currentTimesSlider->setRange(01000);
currentTimesSlider->setSingleStep(100);
currentTimesSlider->setValue(100);
connect(currentTimesSlider SIGNAL(valueChanged(int)) this
SLOT(currentTimesChanged(int)));
QHBoxLayout * layout3 = new QHBoxLayout;
layout3->addWidget(label3);
layout3->addWidget(currentTimesSlider);
okButton = new QPushButton(tr(“确定“) this);
connect(okButton SIGNAL(clicked()) this SLOT(OK()));
QHBoxLayout * layout4 = new QHBoxLayout;
layout4->addWidget(okButton);
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->addLayout(layout1);
mainLayout->addLayout(layout2);
mainLayout->addLayout(layout3);
mainLayout->addLayout(layout4);
setLayout(mainLayout);
}
SelectDialog::~SelectDialog()
{
}
void SelectDialog::bAlgorithmChanged(int value)
{
bAlgorithm = value;
}
void SelectDialog::wAlgorithmChanged(int value)
{
wAlgorithm = value;
}
void SelectDialog::OK()
{
close();
}
void SelectDialog::currentTimesChanged(int value)
{
times = value;
}
void SelectDialog::getValue(int & bAlgo int & wAlgo int & currentTimes)
{
bAlgo = bAlgorithm;
wAlgo = wAlgorithm;
currentTimes = times;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2496 2012-04-23 19:38 单机版五子棋游戏\dialog.cpp
文件 1077 2012-04-23 19:38 单机版五子棋游戏\dialog.h
文件 183 2012-04-23 19:39 单机版五子棋游戏\main.cpp
文件 8296 2012-04-23 19:39 单机版五子棋游戏\window.cpp
文件 1207 2012-04-23 19:39 单机版五子棋游戏\window.h
文件 17262 2012-04-23 19:39 单机版五子棋游戏\Wuziqi.cpp
文件 2582 2012-04-23 19:39 单机版五子棋游戏\Wuziqi.h
目录 0 2012-04-23 19:39 单机版五子棋游戏
----------- --------- ---------- ----- ----
33103 8
- 上一篇:agilent频谱仪控制原代码
- 下一篇:Qt写的网络版五子棋游戏源代码
评论
共有 条评论