全球即時:Qt實現信號燈

2022-12-14 16:07:48 來源:51CTO博客


(資料圖)

//設置背景顏色,橢圓弧度ui->radioButton->setStyleSheet("QRadioButton::indicator{width:35px;height:35px;border-radius:17px}"    "QRadioButton::indicator:checked{background-color:green;}"    "QRadioButton::indicator:unchecked{background-color:red;}");
QVBoxLayout *vbox = new QVBoxLayout(this);        TrafficLightWidget *widget = new TrafficLightWidget();        vbox->addWidget(widget);        vbox->setMargin(0);        QStateMachine *machine = new QStateMachine(this);        QState *redGoingYellow = createLightState(widget->redLight(), 3000);        redGoingYellow->setObjectName("redGoingYellow");        QState *yellowGoingGreen = createLightState(widget->yellowLight(), 1000);        yellowGoingGreen->setObjectName("yellowGoingGreen");        redGoingYellow->addTransition(redGoingYellow, SIGNAL(finished()), yellowGoingGreen);        QState *greenGoingYellow = createLightState(widget->greenLight(), 3000);        greenGoingYellow->setObjectName("greenGoingYellow");        yellowGoingGreen->addTransition(yellowGoingGreen, SIGNAL(finished()), greenGoingYellow);        QState *yellowGoingRed = createLightState(widget->yellowLight(), 1000);        yellowGoingRed->setObjectName("yellowGoingRed");        greenGoingYellow->addTransition(greenGoingYellow, SIGNAL(finished()), yellowGoingRed);        yellowGoingRed->addTransition(yellowGoingRed, SIGNAL(finished()), redGoingYellow);        machine->addState(redGoingYellow);        machine->addState(yellowGoingGreen);        machine->addState(greenGoingYellow);        machine->addState(yellowGoingRed);        machine->setInitialState(redGoingYellow);        machine->start();

標簽: 背景顏色

上一篇:如何升級 CentOS 7 的 Linux 內核
下一篇:天天觀點:分布式數據庫使用 k8s 面臨的困境