Exemple #1
0
void UIcolorEditor::initButtons() {
    const int extraSize = 10;
    int frameSize = CaptureButton::buttonBaseSize() + extraSize;

    m_vLayout->addWidget(new QLabel(tr("Select a Button to modify it"), this));

    QGroupBox *frame = new QGroupBox();
    frame->setFixedSize(frameSize, frameSize);

    m_buttonMainColor = new CaptureButton(m_buttonIconType, frame);
    m_buttonMainColor->move(m_buttonMainColor->x() + extraSize/2, m_buttonMainColor->y() + extraSize/2);
    QHBoxLayout *h1 = new QHBoxLayout();
    h1->addWidget(frame);
    m_labelMain = new ClickableLabel(tr("Main Color"), this);
    h1->addWidget(m_labelMain);
    m_vLayout->addLayout(h1);

    m_buttonMainColor->setToolTip(tr("Click on this button to set the edition"
                                       " mode of the main color."));

    QGroupBox *frame2 = new QGroupBox();
    m_buttonContrast = new CaptureButton(m_buttonIconType, frame2);
    m_buttonContrast->move(m_buttonContrast->x() + extraSize/2,
                           m_buttonContrast->y() + extraSize/2);

    QHBoxLayout *h2 = new QHBoxLayout();
    h2->addWidget(frame2);
    frame2->setFixedSize(frameSize, frameSize);
    m_labelContrast = new ClickableLabel(tr("Contrast Color"), this);
    m_labelContrast->setStyleSheet("color : gray");
    h2->addWidget(m_labelContrast);
    m_vLayout->addLayout(h2);

    m_buttonContrast->setToolTip(tr("Click on this button to set the edition"
                                      " mode of the contrast color."));

    connect(m_buttonMainColor, &CaptureButton::pressedButton,
            this, &UIcolorEditor::changeLastButton);
    connect(m_buttonContrast, &CaptureButton::pressedButton,
            this, &UIcolorEditor::changeLastButton);
    // clicking the labels chages the button too
    connect(m_labelMain, &ClickableLabel::clicked,
            this, [this]{ changeLastButton(m_buttonMainColor); });
    connect(m_labelContrast, &ClickableLabel::clicked,
            this, [this]{ changeLastButton(m_buttonContrast); });
    m_lastButtonPressed = m_buttonMainColor;
}
Exemple #2
0
QGroupBox* createGroupBox(int num)
{
    QGroupBox* gbox = new QGroupBox();
    gbox->setTitle("Plate" + QString::number(num));
    QGridLayout* gridLayout = new QGridLayout();

    int height = 30;
    UutButton* btn1 = new UutButton(1);
    btn1->setText("UUT1\nReady");
    btn1->setFixedHeight(height);

    UutButton* btn2 = new UutButton(1);
    btn2->setText("UUT2\nReady");
    btn2->setFixedHeight(height);

    UutButton* btn3 = new UutButton(1);
    btn3->setText("UUT3\nReady");
    btn3->setFixedHeight(height);

    UutButton* btn4 = new UutButton(1);
    btn4->setText("UUT4\nReady");
    btn4->setFixedHeight(height);

    UutButton* btn5 = new UutButton(1);
    btn5->setText("UUT5\nReady");
    btn5->setFixedHeight(height);

    UutButton* btn6 = new UutButton(1);
    btn6->setText("UUT6\nReady");
    btn6->setFixedHeight(height);

    gridLayout->addWidget(btn1,0,0,1,1);
    gridLayout->addWidget(btn2,0,1,1,1);
    gridLayout->addWidget(btn3,1,0,1,1);
    gridLayout->addWidget(btn4,1,1,1,1);
    gridLayout->addWidget(btn5,2,0,1,1);
    gridLayout->addWidget(btn6,2,1,1,1);

    gbox->setFixedSize(180,140);
    gbox->setLayout(gridLayout);

    UIUtil::setBgColor(gbox, QColor(Qt::gray));
    return gbox;
}
CTestSummaryWindow::CTestSummaryWindow(QWidget *parent) :
    QWidget(parent)
{   
    QVBoxLayout* topLevelLayout = new QVBoxLayout(this);

    QGroupBox* main = new QGroupBox(tr("作业总结"));
    main->setFixedSize(700,520);

    QVBoxLayout* mainLayout = new QVBoxLayout(main);
    mainLayout->setContentsMargins(40,15,40,15);
    mainLayout->setSpacing(20);

    _testSummaryTree = new QTreeWidget;
    _testSummaryTree->setColumnCount(2);
    _testSummaryTree->setHeaderLabels(QStringList() << tr("检测项目") << tr("完成情况") << tr("备注"));
    _testSummaryTree->header()->setStretchLastSection( true);
    _testSummaryTree->header()->setResizeMode( QHeaderView::ResizeToContents );
    _testSummaryTree->model()->setHeaderData(2, Qt::Horizontal, Qt::AlignHCenter, Qt::TextAlignmentRole);
    _testSummaryTree->setSelectionMode(QAbstractItemView::NoSelection);
    _testSummaryTree->setFocusPolicy(Qt::NoFocus);

    QLabel* text = new QLabel(tr("本次测试结果统计表"));
    text->setStyleSheet("font:bold 14px;color:#0099FF;max-height:26px;min-height:26px;background:#CCFF99;padding:0 15px;");

    QPushButton* button = new QPushButton(tr("保存本次记录"));
    button->setStyleSheet("font:14px;min-width:100px;min-height:26px;");

    mainLayout->addWidget(text, 0, Qt::AlignCenter);
    mainLayout->addWidget(_testSummaryTree);
    mainLayout->addWidget(button, 0, Qt::AlignCenter);

    topLevelLayout->addWidget(main, 0, Qt::AlignCenter);
    topLevelLayout->setAlignment(Qt::AlignCenter);
    //***signal
    updateTestSummary();
    connect(button, SIGNAL(clicked()), this, SLOT(finishTestJob()));
}
Exemple #4
0
xyPlot::xyPlot(QTScope* caller, QWidget* parent, const char* name, int id, Qt::WindowFlags wflags, int numberOfSamples)
	: scopePlotPlugin(caller, parent, name, id, wflags,numberOfSamples)
{
  cout << "xyPlot::xyPlot: xyPlot Plugin generated\n";
  callingWidget = caller;
  idThis = id;

  setWindowTitle( QString().sprintf("Channel %s",name) );

  plotLength = numberOfSamples;
  x=new double[plotLength];
  y=new double[plotLength];

  // initialize the data arrays
  clearData();

  // allow Docking
  //setDockEnabled ( Qt::DockTop, TRUE );
  //setDockEnabled ( Qt::DockLeft, TRUE );

  // conmstruct a toolbar
  QVBoxLayout *plotTools = new QVBoxLayout();
  QGroupBox *groupTools = new QGroupBox();

  QLabel *y_max = new QLabel(tr("Y max:"));
  plotTools->addWidget( y_max );
  ymaxCounter = new QwtCounter( );
  plotTools->addWidget( ymaxCounter );
  ymaxCounter->setRange(-1, 20.0);
  ymaxCounter->setSingleStep(0.01);
  ymaxCounter->setNumButtons(2);
  ymaxCounter->setIncSteps(QwtCounter::Button1, 10);
  ymaxCounter->setIncSteps(QwtCounter::Button2, 100);
  ymaxCounter->setValue(1);
  ymaxCounter->resize(200,200);
  connect(ymaxCounter, SIGNAL(valueChanged(double)), this, SLOT(slotYmaxChanged(double)));
  ymaxCounter->setDisabled(TRUE);

  QLabel *y_min = new QLabel(tr("Y min:"));
  plotTools->addWidget( y_min );
  yminCounter = new QwtCounter( );
  plotTools->addWidget( yminCounter );
  yminCounter->setRange(-20.0, 1);
  yminCounter->setSingleStep(0.01);
  yminCounter->setNumButtons(2);
  yminCounter->setIncSteps(QwtCounter::Button1, 10);
  yminCounter->setIncSteps(QwtCounter::Button2, 100);
  yminCounter->setValue(-1);
  connect(yminCounter, SIGNAL(valueChanged(double)), this, SLOT(slotYminChanged(double)));
  yminCounter->setDisabled(TRUE);

  //plotTools->addSeparator();

  QLabel *x_min = new QLabel(tr("X min:"));
  plotTools->addWidget( x_min );
  xminCounter = new QwtCounter( );
  plotTools->addWidget( xminCounter );
  xminCounter->setRange(-20.0, 1);
  xminCounter->setSingleStep(0.01);
  xminCounter->setNumButtons(2);
  xminCounter->setIncSteps(QwtCounter::Button1, 10);
  xminCounter->setIncSteps(QwtCounter::Button2, 100);
  xminCounter->setValue(-1);
  connect(xminCounter, SIGNAL(valueChanged(double)), this, SLOT(slotXminChanged(double)));
  xminCounter->setDisabled(TRUE);

  QLabel *x_max = new QLabel(tr("X max:"));
  plotTools->addWidget( x_max );
  xmaxCounter = new QwtCounter( );
  plotTools->addWidget( xmaxCounter );
  xmaxCounter->setRange(-1, 20.0);
  xmaxCounter->setSingleStep(0.01);
  xmaxCounter->setNumButtons(2);
  xmaxCounter->setIncSteps(QwtCounter::Button1, 10);
  xmaxCounter->setIncSteps(QwtCounter::Button2, 100);
  xmaxCounter->setValue(1);
  connect(xmaxCounter, SIGNAL(valueChanged(double)), this, SLOT(slotXmaxChanged(double)));
  xmaxCounter->setDisabled(TRUE);


  //plotTools->addSeparator();
  QLabel *dataPoints = new QLabel(tr("Data Points:"));
  plotTools->addWidget( dataPoints );
  rangeCounter = new QwtCounter( );
  plotTools->addWidget( rangeCounter );
  rangeCounter->setRange(0, plotLength);
  rangeCounter->setSingleStep(1);
  rangeCounter->setNumButtons(2);
  rangeCounter->setIncSteps(QwtCounter::Button1, 100);
  rangeCounter->setIncSteps(QwtCounter::Button3, 1000);
  rangeCounter->setValue(100);
  connect(rangeCounter, SIGNAL(valueChanged(double)), this, SLOT(slotRangeChanged(double)));
  rangeCounter->setDisabled(FALSE);

  //plotTools->addSeparator();
  autoscaleCheck = new QCheckBox("Autoscale");
  plotTools->addWidget( autoscaleCheck );
  autoscaleCheck->setChecked(TRUE);
  connect(autoscaleCheck, SIGNAL(clicked()), this, SLOT(slotAutoscaleToggled()));

  //moveDockWindow( plotTools, Qt::DockLeft );

  // contruct a QwtPlot Widget
  plotWidget = new QwtPlot(this);

  // QwtPlot specific defaults:
  // colour
  plotWidget->setCanvasBackground(Qt::white);
  // outline
  //plotWidget->enableOutline(FALSE);
  // no legend
  //plotWidget->enableLegend(FALSE);
  
  // no grid
  grid = new QwtPlotGrid();
  grid->enableX(true);
  grid->enableXMin(true);

  // for major grid line
  grid->setMajorPen( QPen(Qt::black,1) );
  // for minor grid line
  grid->setMinorPen( QPen(Qt::gray,1) );

  QwtScaleDiv div;
  QwtLinearScaleEngine *lineSE = new QwtLinearScaleEngine();
  div = lineSE->divideScale(0, 150, 2, 5, 15);
  
  grid->attach( plotWidget );
  
  // set some defaults for the axes
  plotWidget->setAxisTitle(QwtPlot::xBottom, "Amplitude/V");
  plotWidget->setAxisTitle(QwtPlot::yLeft, "Amplitude/V");
  // default xrange
  plotWidget->setAxisScale( QwtPlot::xBottom, 0, 1000);
  // yrange autoscale
  plotWidget->setAxisAutoScale(QwtPlot::yLeft);
  plotWidget->setAxisAutoScale(QwtPlot::xBottom);

  curve = new QwtPlotCurve("Graph");
     
  //set curve color
  curve->setPen(QPen(Qt::green, 2));
     
  // add curves
  curve->attach(plotWidget);
      
  // copy the data into the curves
  curve->setRawSamples(x, y, plotLength);
     
  // finally, refresh the plot
  plotWidget->replot(); 
  
  groupTools->setLayout(plotTools);
  QSize size = groupTools->sizeHint();
  size.setWidth( size.width()*1.3 );
  groupTools->setFixedSize( size );

  QHBoxLayout *hbox = new QHBoxLayout();
  hbox->addWidget(groupTools);
  hbox->addWidget(plotWidget);
  
  setLayout(hbox);
}
Exemple #5
0
void MainWindow::createMainMenuWidget() {
    // Sets up each menu button along with their styleSheet
    QPushButton *start = new QPushButton(tr("Start"));
    start->setFixedSize(172,48);
    start->setFont(QFont("MS Shell Dlg 2", 11, QFont::Bold));
    start->setStyleSheet("QPushButton{background-image:url(:/program/images/Default.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                         "QPushButton:hover{background-image:url(:/program/images/Hover.png);}"
                         "QPushButton:pressed{background-image:url(:/program/images/Clicked.png);}");
    connect(start, SIGNAL(clicked()), this, SLOT(startButtonClicked()));

    QPushButton *howToPlay = new QPushButton(tr("How to Play"));
    howToPlay->setFixedSize(172,48);
    howToPlay->setFont(QFont("MS Shell Dlg 2", 11, QFont::Bold));
    howToPlay->setStyleSheet("QPushButton{background-image:url(:/program/images/About.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                             "QPushButton:hover{background-image:url(:/program/images/About-Hover.png);}"
                             "QPushButton:pressed{background-image:url(:/program/images/About-Clicked.png);}"
                             "QPushButton:disabled{background-image:url(:/program/images/Quit.png);};");
    connect(howToPlay, SIGNAL(clicked()), this, SLOT(howToPlayButtonClicked()));

    QPushButton *about = new QPushButton(tr("About Guess Who"));
    about->setFixedSize(172,48);
    about->setFont(QFont("MS Shell Dlg 2", 11, QFont::Bold));
    about->setStyleSheet("QPushButton{background-image:url(:/program/images/About.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                         "QPushButton:hover{background-image:url(:/program/images/About-Hover.png);}"
                         "QPushButton:pressed{background-image:url(:/program/images/About-Clicked.png);}");
    connect(about, SIGNAL(clicked()), this, SLOT(aboutButtonClicked()));

    QPushButton *quit = new QPushButton(tr("Quit"));
    quit->setFixedSize(172,48);
    quit->setFont(QFont("MS Shell Dlg 2", 11, QFont::Bold));
    quit->setStyleSheet("QPushButton{background-image:url(:/program/images/Quit.png); color: white; border-width: 3px; border-color: #181D1F; border-style: outset; border-radius: 7;}"
                        "QPushButton:hover{background-image:url(:/program/images/Quit-Hover.png);}"
                        "QPushButton:pressed{background-image:url(:/program/images/Quit-Clicked.png);}");
    connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));

    // Creates the layout for the buttons
    QVBoxLayout *buttonLayout = new QVBoxLayout;
    buttonLayout->addSpacing(20);
    buttonLayout->addWidget(start, 0, Qt::AlignHCenter);
    buttonLayout->addSpacing(15);
    buttonLayout->addWidget(howToPlay, 0, Qt::AlignHCenter);
    buttonLayout->addSpacing(15);
    buttonLayout->addWidget(about, 0, Qt::AlignHCenter);
    buttonLayout->addSpacing(15);
    buttonLayout->addWidget(quit, 0, Qt::AlignHCenter);
    buttonLayout->addSpacing(20);

    QGroupBox *choiceGroupBox = new QGroupBox(tr(""));
    choiceGroupBox->setStyleSheet("QGroupBox{color:white}");
    choiceGroupBox->setLayout(buttonLayout);
    choiceGroupBox->setFixedSize(260, 400);

    // Creates 2 labels that will hold images for the menu screen
    QLabel *leftLabel = new QLabel(tr(""));
    QPixmap leftImage(":/program/images/Left.png");
    leftLabel->setPixmap(leftImage);
    leftLabel->setFixedSize(480,570);

    QLabel *rightLabel = new QLabel(tr(""));
    QPixmap rightImage(":/program/images/Right.png");
    rightLabel->setPixmap(rightImage);
    rightLabel->setFixedSize(480,570);

    // Creates the bottom layout for the page
    QHBoxLayout *bottomLayout = new QHBoxLayout;
    bottomLayout->addWidget(leftLabel, 0, Qt::AlignHCenter);
    bottomLayout->addWidget(choiceGroupBox);
    bottomLayout->addWidget(rightLabel, 0, Qt::AlignHCenter);

    // Creates the main layout for the page
    QVBoxLayout *mainLayout = new QVBoxLayout;

    QPixmap titleImage(":/program/images/Title.png");
    QLabel *titleName = new QLabel(tr(""));
    titleName->setPixmap(titleImage);
    titleName->setFixedSize(980,300);

    mainLayout->addSpacing(100);
    mainLayout->addWidget(titleName, 0, Qt::AlignHCenter);
    mainLayout->addLayout(bottomLayout);

    mainMenuWidget = new QWidget;
    mainMenuWidget->setLayout(mainLayout);
}