C++ (Qt)#include "widget.h"#include "ui_widget.h" int tarelka; Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this); d_01 = new detki(100); d_02 = new detki(110); d_03 = new detki(120); d_04 = new detki(130); d_05 = new detki(140); d_06 = new detki(150); d_07 = new detki(160); d_08 = new detki(170); d_09 = new detki(180); d_10 = new detki(190); d_11 = new detki(200); d_12 = new detki(210); d_13 = new detki(220); d_14 = new detki(230); d_15 = new detki(240); d_16 = new detki(250); d_17 = new detki(260); d_18 = new detki(270); d_19 = new detki(280); d_20 = new detki(290); QObject::connect(ui->phButton_01, SIGNAL(clicked()), this, SLOT(MyEventStart())); QObject::connect(d_01, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_02, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_03, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_04, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_05, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_06, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_07, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_08, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_09, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_10, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_11, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_12, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_13, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_14, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_15, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_16, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_17, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_18, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_19, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_20, SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(d_01, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_02, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_03, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_04, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_05, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_06, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_07, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_08, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_09, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_10, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_11, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_12, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_13, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_14, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_15, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_16, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_17, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_18, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_19, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_20, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_01, SIGNAL(DetiInfo(QString)), ui->label_01, SLOT(setText(QString))); QObject::connect(d_02, SIGNAL(DetiInfo(QString)), ui->label_02, SLOT(setText(QString))); QObject::connect(d_03, SIGNAL(DetiInfo(QString)), ui->label_03, SLOT(setText(QString))); QObject::connect(d_04, SIGNAL(DetiInfo(QString)), ui->label_04, SLOT(setText(QString))); QObject::connect(d_05, SIGNAL(DetiInfo(QString)), ui->label_05, SLOT(setText(QString))); QObject::connect(d_06, SIGNAL(DetiInfo(QString)), ui->label_06, SLOT(setText(QString))); QObject::connect(d_07, SIGNAL(DetiInfo(QString)), ui->label_07, SLOT(setText(QString))); QObject::connect(d_08, SIGNAL(DetiInfo(QString)), ui->label_08, SLOT(setText(QString))); QObject::connect(d_09, SIGNAL(DetiInfo(QString)), ui->label_09, SLOT(setText(QString))); QObject::connect(d_10, SIGNAL(DetiInfo(QString)), ui->label_10, SLOT(setText(QString))); QObject::connect(d_11, SIGNAL(DetiInfo(QString)), ui->label_11, SLOT(setText(QString))); QObject::connect(d_12, SIGNAL(DetiInfo(QString)), ui->label_12, SLOT(setText(QString))); QObject::connect(d_13, SIGNAL(DetiInfo(QString)), ui->label_13, SLOT(setText(QString))); QObject::connect(d_14, SIGNAL(DetiInfo(QString)), ui->label_14, SLOT(setText(QString))); QObject::connect(d_15, SIGNAL(DetiInfo(QString)), ui->label_15, SLOT(setText(QString))); QObject::connect(d_16, SIGNAL(DetiInfo(QString)), ui->label_16, SLOT(setText(QString))); QObject::connect(d_17, SIGNAL(DetiInfo(QString)), ui->label_17, SLOT(setText(QString))); QObject::connect(d_18, SIGNAL(DetiInfo(QString)), ui->label_18, SLOT(setText(QString))); QObject::connect(d_19, SIGNAL(DetiInfo(QString)), ui->label_19, SLOT(setText(QString))); QObject::connect(d_20, SIGNAL(DetiInfo(QString)), ui->label_20, SLOT(setText(QString)));} Widget::~Widget(){ delete d_01, d_02, d_03, d_04, d_05; delete d_06, d_07, d_08, d_09, d_10; delete d_11, d_12, d_13, d_14, d_15; delete d_16, d_17, d_18, d_19, d_20; delete ui;} // кнопка Startvoid Widget::MyEventStart(){ tarelka = 100; d_01->start(); d_02->start(); d_03->start(); d_04->start(); d_05->start(); d_06->start(); d_07->start(); d_08->start(); d_09->start(); d_10->start(); d_11->start(); d_12->start(); d_13->start(); d_14->start(); d_15->start(); d_16->start(); d_17->start(); d_18->start(); d_19->start(); d_20->start(); } void Widget::TarelkaView(){ ui->label_mama->setText(QString::number(tarelka)); } void Widget::MamaWork(){ static int cx = 0; if(tarelka == 0) tarelka = 100; ui->label_22->setText(QString::number(++cx));}
C++ (Qt)void detki::run(){ this->setPriority(QThread::IdlePriority); // приоритет потока while(1) { for (int i = 0; i < 20; i++) { emit DetiInfo(QString::number(i)); this->msleep(appetit); } emit TarelkaInfo(); if(tarelka > 0) tarelka--; else emit MamaHelp(); } exec();}
C++ (Qt) QObject::connect(d_01, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_02, SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(d_03, SIGNAL(MamaHelp()), this, SLOT(MamaWork()));...
C++ (Qt) if(tarelka > 0) tarelka--; else emit MamaHelp();}
C++ (Qt)Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this); d_01 = new detki(50); dd[0] = d_01; d_02 = new detki(60); dd[1] = d_02; d_03 = new detki(70); dd[2] = d_03; d_04 = new detki(80); dd[3] = d_04; d_05 = new detki(90); dd[4] = d_05; d_06 = new detki(100); dd[5] = d_06; d_07 = new detki(110); dd[6] = d_07; d_08 = new detki(120); dd[7] = d_08; d_09 = new detki(130); dd[8] = d_09; d_10 = new detki(140); dd[9] = d_10; d_11 = new detki(150); dd[10] = d_11; d_12 = new detki(160); dd[11] = d_12; d_13 = new detki(170); dd[12] = d_13; d_14 = new detki(180); dd[13] = d_14; d_15 = new detki(190); dd[14] = d_15; d_16 = new detki(200); dd[15] = d_16; d_17 = new detki(210); dd[16] = d_17; d_18 = new detki(220); dd[17] = d_18; d_19 = new detki(230); dd[18] = d_19; d_20 = new detki(240); dd[19] = d_20; QObject::connect(ui->phButton_01, SIGNAL(clicked()), this, SLOT(MyEventStart())); for(int i = 0; i < 20; i++) { QObject::connect(dd[i], SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(dd[i], SIGNAL(MamaHelp()), this, SLOT(MamaWork())); } QObject::connect(dd[0], SIGNAL(DetiInfo(QString)), ui->label_01, SLOT(setText(QString))); QObject::connect(dd[1], SIGNAL(DetiInfo(QString)), ui->label_02, SLOT(setText(QString))); QObject::connect(d_03, SIGNAL(DetiInfo(QString)), ui->label_03, SLOT(setText(QString))); QObject::connect(d_04, SIGNAL(DetiInfo(QString)), ui->label_04, SLOT(setText(QString))); QObject::connect(d_05, SIGNAL(DetiInfo(QString)), ui->label_05, SLOT(setText(QString))); QObject::connect(d_06, SIGNAL(DetiInfo(QString)), ui->label_06, SLOT(setText(QString))); QObject::connect(d_07, SIGNAL(DetiInfo(QString)), ui->label_07, SLOT(setText(QString))); QObject::connect(d_08, SIGNAL(DetiInfo(QString)), ui->label_08, SLOT(setText(QString))); QObject::connect(d_09, SIGNAL(DetiInfo(QString)), ui->label_09, SLOT(setText(QString))); QObject::connect(d_10, SIGNAL(DetiInfo(QString)), ui->label_10, SLOT(setText(QString))); QObject::connect(d_11, SIGNAL(DetiInfo(QString)), ui->label_11, SLOT(setText(QString))); QObject::connect(d_12, SIGNAL(DetiInfo(QString)), ui->label_12, SLOT(setText(QString))); QObject::connect(d_13, SIGNAL(DetiInfo(QString)), ui->label_13, SLOT(setText(QString))); QObject::connect(d_14, SIGNAL(DetiInfo(QString)), ui->label_14, SLOT(setText(QString))); QObject::connect(d_15, SIGNAL(DetiInfo(QString)), ui->label_15, SLOT(setText(QString))); QObject::connect(d_16, SIGNAL(DetiInfo(QString)), ui->label_16, SLOT(setText(QString))); QObject::connect(d_17, SIGNAL(DetiInfo(QString)), ui->label_17, SLOT(setText(QString))); QObject::connect(d_18, SIGNAL(DetiInfo(QString)), ui->label_18, SLOT(setText(QString))); QObject::connect(d_19, SIGNAL(DetiInfo(QString)), ui->label_19, SLOT(setText(QString))); QObject::connect(d_20, SIGNAL(DetiInfo(QString)), ui->label_20, SLOT(setText(QString)));}
C++ (Qt)Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this); d_01 = new detki(50); dd[0] = d_01; lb[0] = ui->label_01; d_02 = new detki(60); dd[1] = d_02; lb[1] = ui->label_02; d_03 = new detki(70); dd[2] = d_03; lb[2] = ui->label_03; d_04 = new detki(80); dd[3] = d_04; lb[3] = ui->label_04; d_05 = new detki(90); dd[4] = d_05; lb[4] = ui->label_05; d_06 = new detki(100); dd[5] = d_06; lb[5] = ui->label_06; d_07 = new detki(110); dd[6] = d_07; lb[6] = ui->label_07; d_08 = new detki(120); dd[7] = d_08; lb[7] = ui->label_08; d_09 = new detki(130); dd[8] = d_09; lb[8] = ui->label_09; d_10 = new detki(140); dd[9] = d_10; lb[9] = ui->label_10; d_11 = new detki(150); dd[10] = d_11; lb[10] = ui->label_11; d_12 = new detki(160); dd[11] = d_12; lb[11] = ui->label_12; d_13 = new detki(170); dd[12] = d_13; lb[12] = ui->label_13; d_14 = new detki(180); dd[13] = d_14; lb[13] = ui->label_14; d_15 = new detki(190); dd[14] = d_15; lb[14] = ui->label_15; d_16 = new detki(200); dd[15] = d_16; lb[15] = ui->label_16; d_17 = new detki(210); dd[16] = d_17; lb[16] = ui->label_17; d_18 = new detki(220); dd[17] = d_18; lb[17] = ui->label_18; d_19 = new detki(230); dd[18] = d_19; lb[18] = ui->label_19; d_20 = new detki(240); dd[19] = d_20; lb[19] = ui->label_20; for(int i = 0; i < 20; i++) { QObject::connect(dd[i], SIGNAL(TarelkaInfo()), this, SLOT(TarelkaView())); QObject::connect(dd[i], SIGNAL(MamaHelp()), this, SLOT(MamaWork())); QObject::connect(dd[i], SIGNAL(DetiInfo(QString)), lb[i], SLOT(setText(QString))); } QObject::connect(ui->phButton_01, SIGNAL(clicked()), this, SLOT(MyEventStart()));}