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


C++ QSignalTransition::setTargetState方法代码示例

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


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

示例1: qWarning

/*!
  Adds a transition associated with the given \a signal of the given \a sender
  object, and returns the new QSignalTransition object. The transition has
  this state as the source, and the given \a target as the target state.
*/
QSignalTransition *QState::addTransition(QObject *sender, const char *signal,
                                         QAbstractState *target)
{
    if (!sender) {
        qWarning("QState::addTransition: sender cannot be null");
        return 0;
    }
    if (!signal) {
        qWarning("QState::addTransition: signal cannot be null");
        return 0;
    }
    if (!target) {
        qWarning("QState::addTransition: cannot add transition to null state");
        return 0;
    }
    int offset = (*signal == '0'+QSIGNAL_CODE) ? 1 : 0;
    const QMetaObject *meta = sender->metaObject();
    if (meta->indexOfSignal(signal+offset) == -1) {
        if (meta->indexOfSignal(QMetaObject::normalizedSignature(signal+offset)) == -1) {
            qWarning("QState::addTransition: no such signal %s::%s",
                     meta->className(), signal+offset);
            return 0;
        }
    }
    QSignalTransition *trans = new QSignalTransition(sender, signal);
    trans->setTargetState(target);
    addTransition(trans);
    return trans;
}
开发者ID:maxxant,项目名称:qt,代码行数:34,代码来源:qstate.cpp

示例2: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
// Загружаем интерфейс пользователя из формы и устанавливаем действия в меню
    ui->setupUi(this);
    connect(ui->action_start, SIGNAL(triggered()), ui->startButton, SLOT(click()));
    connect(ui->action_exit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->action_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(ui->action_help, SIGNAL(triggered()), this, SLOT(showHelp()));
    connect(ui->action_about, SIGNAL(triggered()), this, SLOT(showAbout()));
    connect(ui->action_tech, SIGNAL(triggered()), this, SLOT(showTz()));
// Заводим машину состояний
    QStateMachine *animation = new QStateMachine(this);
    QState *idle = new QState();
    QState *animating = new QState();
    animating->assignProperty(ui->startButton,"text", tr("&Стоп"));
    animating->assignProperty(ui->startButton,"icon", QIcon(":/icons/control-stop-square.png"));
    animating->assignProperty(ui->action_start,"text",tr("О&становить анимацию"));
    animating->assignProperty(ui->action_start,"icon", QIcon(":/icons/control-stop-square.png"));
    idle->assignProperty(ui->startButton,"text", tr("Пу&ск"));
    idle->assignProperty(ui->startButton,"icon", QIcon(":/icons/control.png"));
    idle->assignProperty(ui->action_start,"text",tr("Запу&стить анимацию"));
    idle->assignProperty(ui->action_start,"icon", QIcon(":/icons/control.png"));
    QSignalTransition *startTransition = new QSignalTransition(ui->startButton, SIGNAL(clicked()), idle);
    startTransition->setTargetState(animating);
    QSignalTransition *stopTransition = new QSignalTransition(ui->startButton, SIGNAL(clicked()), animating);
    stopTransition->setTargetState(idle);
    QSignalTransition *doneTransition = new QSignalTransition(ui->widget, SIGNAL(animationStopped()), animating);
    doneTransition->setTargetState(idle);
    connect(startTransition, SIGNAL(triggered()), ui->widget, SLOT(startAnimation()));
    connect(stopTransition, SIGNAL(triggered()), ui->widget, SLOT(stopAnimation()));
    idle->addTransition(startTransition);
    animating->addTransition(stopTransition);
    animating->addTransition(doneTransition);
    animation->addState(idle);
    animation->addState(animating);
    animation->setInitialState(idle);
    animation->start();
 // В Linux мячик иногда сразу не отображается...
    ui->widget->updateGL();
}
开发者ID:Envek,项目名称:ECGKW,代码行数:42,代码来源:mainwindow.cpp


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