#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "channel.h" ADC::ADC(QWidget *parent) : QWidget(parent) { QLCDNumber *lcd = new QLCDNumber(8); lcd->setSegmentStyle(QLCDNumber::Flat); lcd->display(2.568001); QLabel *unit = new QLabel(); unit->setText(" Volts"); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(lcd); layout->addWidget(unit); setLayout(layout); } Choice::Choice(int val, QWidget *parent) : QWidget(parent) { QLabel *label = new QLabel(this); label->setText("Channel " + QString::number(val) + " : "); combo = new QComboBox(this); combo->addItem("In"); combo->addItem("Out"); combo->addItem("ADC"); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(label); layout->addWidget(combo); setLayout(layout); connect(combo, SIGNAL(currentIndexChanged(int)),this, SIGNAL(currentIndexChanged(int))); } Data::Data(QWidget *parent) : QWidget(parent) { widg = new QWidget(this); adc = new ADC(); lcd = new QLCDNumber(1); widg = lcd; } Channel::Channel(int n,QWidget *parent) : QWidget(parent) { Choice *choice = new Choice(n,this); Data *data = new Data(this); QHBoxLayout *chlay = new QHBoxLayout; chlay->addWidget(choice); chlay->addWidget(data); setLayout(chlay); connect(choice, SIGNAL(currentIndexChanged(int)),data, SLOT(DataUpdate(int))); } MyWidget::MyWidget(QWidget *parent) : QWidget(parent) { QPushButton *quit = new QPushButton(tr("Quit")); quit->setFont(QFont("Times", 18, QFont::Bold)); connect(quit, SIGNAL(clicked()), qApp, SLOT(quit())); QVBoxLayout *lay = new QVBoxLayout; for (int row=0;row<8;row++){ Channel *ch = new Channel(row,this); lay->addWidget(ch); } QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(quit); layout->addLayout(lay); setLayout(layout); } void Data::DataUpdate(int value) { if(value == 2) widg = adc; else widg = lcd; lcd->display(value); Data::update(); } int main(int argc, char *argv[]) { QStyle *stylea = new QCleanlooksStyle(); QApplication app(argc, argv); app.setStyle(stylea); MyWidget widget; widget.show(); return app.exec(); }