当前位置: 首页>>代码示例>>C++>>正文


C++ QState::property方法代码示例

本文整理汇总了C++中QState::property方法的典型用法代码示例。如果您正苦于以下问题:C++ QState::property方法的具体用法?C++ QState::property怎么用?C++ QState::property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QState的用法示例。


在下文中一共展示了QState::property方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onStateExited

    void onStateExited()
    {
        QState *state = qobject_cast<QState*>(sender());
        switch (state->property("type").toInt()) {
        case Normal: {
            int idx = rand() % d.frames.size();
            while (d.frames.at(idx)->status != Frame::Hidden) {
                if (++idx == d.frames.size())
                    idx = 0;
            }
            Q_ASSERT(!d.currentFrame);
            d.currentFrame = d.frames.at(idx);
            Q_ASSERT(d.currentFrame->status == Frame::Hidden);
            --d.framesLeft;
            break; }
        default:
            break;
        }
//        qDebug() << sender()->objectName() << "exited";
    }
开发者ID:Andersbakken,项目名称:Jeopardy,代码行数:20,代码来源:main.cpp

示例2: onStateEntered

    void onStateEntered()
    {
        QState *state = qobject_cast<QState*>(sender());
        const int type = state->property("type").toInt();
        switch (type) {
        case Normal:
            Q_ASSERT(d.teamsAttempted.isEmpty());
            Q_ASSERT(!d.currentTeam);
            Q_ASSERT(!d.currentFrame);
            break;
        case ShowQuestion: {
            if (d.teamsAttempted.size() == d.teams.size()) {
                emit nextStateTimeOut();
            } else {
                Q_ASSERT(d.currentFrame);
//                 qDebug() << "showing question" << d.currentFrame->question
//                          << "worth" << d.currentFrame->value << "$";
            }
            break; }
        case TimeOut:
            Q_ASSERT(d.currentFrame);
            d.currentFrame->status = Frame::Failed;
            finishQuestion();
            break;
        case PickTeam:
            Q_ASSERT(!d.currentTeam);
            Q_ASSERT(d.teamsAttempted.size() < d.teams.size());
            do {
                d.currentTeam = d.teams.at(rand() % d.teams.size());
            } while (d.teamsAttempted.contains(d.currentTeam));
            d.teamsAttempted.insert(d.currentTeam);
            break;
        case TeamTimedOut:
            ++d.timedout;
        case WrongAnswer:
            if (type == WrongAnswer)
                ++d.wrong;
            Q_ASSERT(d.currentTeam);
            Q_ASSERT(d.currentFrame);
            d.currentTeam->score -= d.currentFrame->value / 2;
//             qDebug() << d.currentTeam->name
//                      << (state->property("type").toInt() == TeamTimedOut
//                          ? "Didn't answer in time" : "Answered wrong")
//                      << "They lost" << (d.currentFrame->value / 2) << "$. They now have"
//                      << d.currentTeam->score << "$";
            d.currentTeam = 0;
            break;
        case RightAnswer:
            ++d.right;
            Q_ASSERT(d.currentTeam);
            Q_ASSERT(d.currentFrame);
            d.currentTeam->score += d.currentFrame->value;
//             qDebug() << d.currentTeam->name << "answered correctly and earned" << d.currentFrame->value
//                      << "$. They now have" << d.currentTeam->score << "$";
            finishQuestion();
            break;
        case Finished:
            qSort(d.teams.end(), d.teams.begin(), compareTeamsByScore);
            for (int i=0; i<d.teams.size(); ++i) {
                qDebug() << i << d.teams.at(i)->score << d.teams.at(i)->name;
            }
            qDebug() << "right" << d.right << "wrong" << d.wrong << "timedout" << d.timedout;
            d.stateMachine.stop();
            QTimer::singleShot(500, this, SLOT(newGame()));
            break;
        }
//        qDebug() << sender()->objectName() << "entered";
    }
开发者ID:Andersbakken,项目名称:Jeopardy,代码行数:68,代码来源:main.cpp


注:本文中的QState::property方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。