Beispiel #1
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Chess w;
    w.show();

    return a.exec();
}
void ChessSelectionWidget::okPushButtonClicked()
{
    if(isOK())
    {
        ChessType type = AIType;
        QString stype(tr("ai"));
        if(serverRadioButton->isChecked())
        {
            type = ServerType;
            stype = tr("server");
        }
        else if(clientRadioButton->isChecked())
        {
            type = ClientType;
            stype = tr("client");
        }
        else if(replayRadioButton->isChecked())
        {
            type = ReplayType;
            stype = tr("replay");
        }
        ChessColor color = RedColor;
        QString scolor("red");
        if(ClientType == type)
        {
            color = BlackColor;
            scolor = tr("black");
        }
        Chess_Info(tr("your selection: type=%1 color=%2 ip=%3 port=%4")
                   .arg(stype)
                   .arg(scolor)
                   .arg(ipLineEdit->text())
                   .arg(portSpinBox->value()));
        ChessInformation *ci = ChessInformation::instance();
        ci->init(type, color, ipLineEdit->text(), portSpinBox->value());
        Chess *chess = Chess::instance();
        chess->setAttribute(Qt::WA_DeleteOnClose);  //窗口关闭时自动删除
        this->hide();
        chess->show();
    }
    else
    {
        Chess_Warning(tr("error input, please check!"));
        QMessageBox::warning(this, tr("ERROR INPUT"), tr("ERROR INPUT, PLEASE CHECK!"));
    }
}