示例#1
0
LCDRange::LCDRange( QWidget *parent, const char *name ): QWidget( parent, name )
{
	//QLCDNumber *lcd = new QLCDNumber( 2, this,  "lcd" );
	QLCDNumber *lcd = new QLCDNumber( 2 );
	lcd->setSegmentStyle(QLCDNumber::Filled);

	//slider = new QSlider( Horizontal, this, "slider" );
	slider = new QSlider( Horizontal);
	slider->setRange( 0, 99 );
	slider->setValue( 0 );

	//设置滑块为焦点代理。当想要给LCDRange一个键盘焦点,滑块就会注意到它。
	setFocusProxy( slider );

	//这里把slider的valueChanged信号分别连接到display和自定义的valueChanged上面
	connect( slider, SIGNAL(valueChanged(int)), lcd,
			SLOT(display(int)) );

	//这里两种方式实现信号的连接,利用标准信号发出自定义信号。
	//connect( slider, SIGNAL(valueChanged(int)),
	//		SIGNAL(valueChanged(int)) );
	connect( slider, SIGNAL(valueChanged(int)), this,
			SIGNAL(valueChanged(int)) );

	//这里利用另外的方式实现添加到VBox,而不用继承QVBox类
	Q3VBoxLayout *layout = new Q3VBoxLayout;
	layout->addWidget(lcd);
	layout->addWidget(slider);
	setLayout(layout);

}
示例#2
0
文件: main.cpp 项目: MakSim345/QT-Dev
 MyWidget::MyWidget(QWidget *parent)
     : QWidget(parent)
 {
     // QPushButton *quit = new QPushButton(tr("Quit"));
     QToolButton *quit = new QToolButton();
     quit->setText(tr("Quit"));
     quit->setFont(QFont("Times", 18, QFont::Bold));
     quit->setMinimumSize(150, 50);

     QLCDNumber *lcd = new QLCDNumber(2);
     lcd->setSegmentStyle(QLCDNumber::Filled);
     lcd->setMinimumSize(150, 150);

     QSlider *slider = new QSlider(Qt::Horizontal);
     slider->setRange(0, 99);
     slider->setValue(0);

     connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
     connect(slider, SIGNAL(valueChanged(int)),
             lcd, SLOT(display(int)));

     QVBoxLayout *layout = new QVBoxLayout;
     
     layout->addWidget(lcd);
     layout->addWidget(slider);
     layout->addWidget(quit);
     
     setLayout(layout);
 }
示例#3
0
 void LCDRange::init()
 {
     QLCDNumber *lcd = new QLCDNumber(2);
     lcd->setSegmentStyle(QLCDNumber::Filled);

     slider = new QSlider(Qt::Horizontal);
     slider->setRange(0, 99);
     slider->setValue(0);
     label = new QLabel;
     label->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
     label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);

     connect(slider, SIGNAL(valueChanged(int)),
             lcd, SLOT(display(int)));
     connect(slider, SIGNAL(valueChanged(int)),
             this, SIGNAL(valueChanged(int)));

     QVBoxLayout *layout = new QVBoxLayout;
     layout->addWidget(lcd);
     layout->addWidget(slider);
     layout->addWidget(label);
     setLayout(layout);

     setFocusProxy(slider);
 }
示例#4
0
myWidget::myWidget(QWidget *parent):QWidget(parent)
{
  //setFixedSize(200,120);
  QPushButton *quit = new QPushButton(tr("Quit"), this);
  //quit->setGeometry(62,40,75,30);
  quit->setFont(QFont("Times", 18, QFont::Bold));

  QLCDNumber *lcd = new QLCDNumber();
  lcd->setSegmentStyle(QLCDNumber::Filled);
  QSlider *slider = new QSlider(Qt::Horizontal);
  //slider->setMaximum(100);
  //slider->setMinimum(0);
  slider->setRange(0,99);
  slider->setPageStep(1);
  slider->setTickInterval(1);
  slider->setTickPosition(QSlider::TicksBelow);
  QVBoxLayout *vLayout = new QVBoxLayout();
  vLayout->addWidget(quit);
  vLayout->addWidget(lcd);
  vLayout->addWidget(slider);
  setLayout(vLayout);

  //BUG!QObject::connect(quit, SIGNAL(clicked()), this, SLOT(quit()));
  QObject::connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
  QObject::connect(slider, SIGNAL(valueChanged(int)), 
		   lcd, SLOT(display(int)));
  QObject::connect(lcd, SIGNAL(overflow()), qApp, SLOT(quit()));
}
示例#5
0
 MyWidget::MyWidget(QWidget *parent)
     : QWidget(parent)
 {
     //setFixedSize(150, 200);

     button_power = new QPower(this);
	 // aerobutton_test = new AeroButton("Test", this);
	 QPushButton *quit = new QPushButton(tr("Quit"));
	 
	 QVBoxLayout *layout = new QVBoxLayout;
	 // QHBoxLayout *layout = new QHBoxLayout;
	 
	 quit->setFont(QFont("Times", 25, QFont::Bold));
	 //aerobutton_test->setFont(QFont("Times", 12, QFont::Bold));
	 //aerobutton_quit->setGeometry(10, 20, 230, 40);
	 //aerobutton_test->setGeometry(10, 70, 230, 40);
	 
	 /*
	 QGridLayout *grid = new QGridLayout;
     for (int row = 0; row < 3; ++row)
     {
      for (int column = 0; column < 2; ++column) 
      {
       LCDRange *lcdRange = new LCDRange;
       grid->addWidget(lcdRange, row, column);
      }
     }
	*/	
	  
	QLCDNumber *lcd = new QLCDNumber(2);
    lcd->setSegmentStyle(QLCDNumber::Filled);
    
    QSlider *slider = new QSlider(Qt::Horizontal);
    slider->setRange(0, 99);
    slider->setValue(0);
    
    //QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(lcd);
    layout->addWidget(slider);
    //setLayout(layout);
	     
     // layout->addWidget(aerobutton_test);
     // layout->addLayout(grid);
     layout->addWidget(button_power);
     layout->addWidget(quit);
     //layout->addWidget(slider);
     setLayout(layout);
        
	 //QObject::connect(aerobutton_quit, SIGNAL(clicked()), &app, SLOT(quit()));
     // connect(aerobutton_quit, SIGNAL(clicked()), qApp, SLOT(quit()));
     // connect(aerobutton_quit, SIGNAL(clicked()), this, SLOT(closeApp() ));
     //connect(aerobutton_test, SIGNAL(clicked()), this, SLOT(showMessageBox() ));
     connect(quit, SIGNAL(clicked()), this, SLOT(closeApp() ));
     connect(button_power, SIGNAL(clicked()), this, SLOT(showMessageBox() ));
     connect(slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)));
     
     //connect(quit, SIGNAL(clicked()), this, SLOT(close() ));
     // connect(button_power, SIGNAL(mousePressEvent()), this, SLOT(close() ));
 }
示例#6
0
LCDRange::LCDRange( QWidget* parent ) : QWidget( parent )
{
    QLCDNumber* lcd = new QLCDNumber(2);
    lcd->setSegmentStyle(QLCDNumber::Filled);

    QSlider* slider = new QSlider(Qt::Horizontal);
    slider->setRange( 0, 99 );
    slider->setValue( 0 );
    connect(slider, SIGNAL( valueChanged( int )), lcd, SLOT( display( int )));

    QVBoxLayout* layout = new QVBoxLayout;
    layout->addWidget( lcd );
    layout->addWidget( slider );
    setLayout( layout );
}
示例#7
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    Progress prog;
    QWidget wgt;

    QLabel* lbl = new QLabel("&Decimal value:");
    QSpinBox* box = new QSpinBox;
    box->setMaximum(1000);
    lbl->setBuddy(box);

    QLCDNumber* lcd = new QLCDNumber(12);
    lcd->setSegmentStyle(QLCDNumber::Flat);
    lcd->setBinMode();
    QLabel* lbl2 = new QLabel("Binary value:");
    QObject::connect(box, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)));

    QLabel* lblurl = new QLabel("<a href=\"http://img12.nnm.me/7/b/a/8/7/7ba875b7bd80980f79ac6cae68418e77_full.jpg\">Нажми-ка!</a>");
    lblurl->setOpenExternalLinks(true);

    QVBoxLayout* layout = new QVBoxLayout;
    layout->addWidget(lbl);
    layout->addWidget(box);
    layout->addWidget(lbl2);
    layout->addWidget(lcd);
    layout->addWidget(lblurl);
    wgt.setLayout(layout);

    QSplitter split(Qt::Horizontal);
    split.addWidget(&prog);
    split.addWidget(&wgt);
    split.setGeometry(500,300,444,200);

    split.show();

    return a.exec();
}
示例#8
0
LCDRange::LCDRange(QWidget *parent)
    :QWidget(parent)
{
    QLCDNumber *lcd = new QLCDNumber(2);
    lcd->setSegmentStyle(QLCDNumber::Flat);
    //lcd->setSegmentStyle(QLCDNumber::Filled);
    lcd->setNumDigits(3);
    lcd->display(5);

    QSlider *slider = new QSlider(Qt::Horizontal);
    slider->setRange(0, 199);
    //slider->sizeHint();
    //slider->minimumSizeHint();
    slider->setValue(5);

    connect(slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)));
    connect(slider, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(lcd);
    layout->addWidget(slider);
    setLayout(layout);
}
示例#9
0
FontPropertyWidget::FontPropertyWidget(FontProperty* prop, QWidget* parent)
    : QPropertyWidget(prop, parent)
    , property_(prop)
{
    groupBox_ = new QGroupBox(this);
    addWidget(groupBox_);

    QVBoxLayout* tgtFontLayout = new QVBoxLayout(groupBox_);
    tgtFontLayout->setContentsMargins(2,2,2,2);

    tgtFontType_ = new QComboBox();
    tgtFontType_->addItem("Bitmap", (int)tgt::Font::BitmapFont);
    tgtFontType_->addItem("Buffer", (int)tgt::Font::BufferFont);
    tgtFontType_->addItem("Extrude", (int)tgt::Font::ExtrudeFont);
    tgtFontType_->addItem("Outline", (int)tgt::Font::OutlineFont);
    tgtFontType_->addItem("Pixmap", (int)tgt::Font::PixmapFont);
    tgtFontType_->addItem("Polygon", (int)tgt::Font::PolygonFont);
    tgtFontType_->addItem("Texture", (int)tgt::Font::TextureFont);
    tgtFontLayout->addWidget(tgtFontType_);

    tgtFontName_ = new QComboBox();
    tgtFontName_->addItem("VeraMono", "VeraMono.ttf");
    tgtFontName_->addItem("Vera", "Vera.ttf");
    tgtFontLayout->addWidget(tgtFontName_);

    QLabel* fontSizeLabel = new QLabel("Fontsize:");
    tgtFontLayout->addWidget(fontSizeLabel);

    QWidget* tgtFontSize = new QWidget();
    QHBoxLayout* tgtFontSizeLayout = new QHBoxLayout(tgtFontSize);
    tgtFontSizeLayout->setContentsMargins(0,0,0,0);
    tgtFontSizeSlider_ = new QSlider(Qt::Horizontal);
    tgtFontSizeLayout->addWidget(tgtFontSizeSlider_);
    QLCDNumber* tgtFontSizeLCD = new QLCDNumber(2);
    tgtFontSizeLayout->addWidget(tgtFontSizeLCD);
    tgtFontLayout->addWidget(tgtFontSize);

    QLabel* lineWidthLabel = new QLabel("Line width:");
    tgtFontLayout->addWidget(lineWidthLabel);

    QWidget* tgtLineWidth = new QWidget();
    QHBoxLayout* tgtLineWidthLayout = new QHBoxLayout(tgtLineWidth);
    tgtLineWidthLayout->setContentsMargins(0,0,0,0);
    tgtLineWidthSlider_ = new QSlider(Qt::Horizontal);
    tgtLineWidthLayout->addWidget(tgtLineWidthSlider_);
    QLCDNumber* tgtLineWidthLCD = new QLCDNumber(3);
    tgtLineWidthLayout->addWidget(tgtLineWidthLCD);
    tgtFontLayout->addWidget(tgtLineWidth);

    tgtTextAlign_ = new QComboBox();
    tgtTextAlign_->addItem("Left", (int)tgt::Font::Left);
    tgtTextAlign_->addItem("Center", (int)tgt::Font::Center);
    tgtTextAlign_->addItem("Right", (int)tgt::Font::Right);
    tgtFontLayout->addWidget(tgtTextAlign_);

    tgtVerticalTextAlign_ = new QComboBox();
    tgtVerticalTextAlign_->addItem("Top", (int)tgt::Font::Top);
    tgtVerticalTextAlign_->addItem("Middle", (int)tgt::Font::Middle);
    tgtVerticalTextAlign_->addItem("Bottom", (int)tgt::Font::Bottom);
    tgtFontLayout->addWidget(tgtVerticalTextAlign_);

    tgtFontSizeLCD->setSegmentStyle(QLCDNumber::Filled);
    tgtLineWidthLCD->setSegmentStyle(QLCDNumber::Filled);

    tgtFontSizeSlider_->setMinimum(6);
    tgtFontSizeSlider_->setMaximum(36);

    tgtLineWidthSlider_->setMinimum(10);
    tgtLineWidthSlider_->setMaximum(999);

    connect(tgtFontType_,        SIGNAL(activated(int)),     this,            SLOT(updateProperty()));
    connect(tgtFontName_,        SIGNAL(activated(int)),     this,            SLOT(updateProperty()));
    connect(tgtFontSizeSlider_,  SIGNAL(valueChanged(int)),  this,            SLOT(updateProperty()));
    connect(tgtFontSizeSlider_,  SIGNAL(valueChanged(int)),  tgtFontSizeLCD,  SLOT(display(int)));
    connect(tgtLineWidthSlider_, SIGNAL(valueChanged(int)),  this,            SLOT(updateProperty()));
    connect(tgtLineWidthSlider_, SIGNAL(valueChanged(int)),  tgtLineWidthLCD, SLOT(display(int)));

    connect(tgtTextAlign_,        SIGNAL(currentIndexChanged(int)),     this,            SLOT(updateProperty()));
    connect(tgtVerticalTextAlign_,SIGNAL(currentIndexChanged(int)),     this,            SLOT(updateProperty()));

    updateFromProperty();
    addVisibilityControls();
}
示例#10
0
TetrisWindow::TetrisWindow()
{
    board = new TetrisBoard;

    nextPieceLabel = new QLabel;
    nextPieceLabel->setFrameStyle(QFrame::Box | QFrame::Raised);
    nextPieceLabel->setAlignment(Qt::AlignCenter);
    nextPieceLabel->setMinimumHeight(100);
    board->setNextPieceLabel(nextPieceLabel);

    levelLcd = new QLCDNumber(7);
    levelLcd->setSegmentStyle(QLCDNumber::Filled);
    linesLcd = new QLCDNumber(7);
    linesLcd->setSegmentStyle(QLCDNumber::Filled);

    QLCDNumber* tetrominoesPlayedLCD = new QLCDNumber(5);
    tetrominoesPlayedLCD->setSegmentStyle(QLCDNumber::Filled);

    DigitalClock* digitalClock = new DigitalClock();


    startButton = new QPushButton(tr("&Start"));
    startButton->setFocusPolicy(Qt::NoFocus);
    quitButton = new QPushButton(tr("&Quit"));
    quitButton->setFocusPolicy(Qt::NoFocus);
    pauseButton = new QPushButton(tr("&Pause"));
    pauseButton->setFocusPolicy(Qt::NoFocus);
    pauseButton->setCheckable(true);

    QGroupBox *aiSelector = new QGroupBox(tr("Select AI"));

    QRadioButton *noneRadio = new QRadioButton(tr("None"));
    QRadioButton *greedyRadio = new QRadioButton(tr("Greedy"));
    QRadioButton *reinforcementRadio = new QRadioButton(tr("Reinforcement"));
    reinforcementRadio->setChecked(true);

    QCheckBox *autoPlayCheckBox = new QCheckBox(tr("Auto Play"));
    QCheckBox *lineDownCheckBox = new QCheckBox(tr("Line Down Timeout"));
    lineDownCheckBox->setChecked(true);
    QCheckBox *invisiblePlayCheckBox = new QCheckBox(tr("Play without gui"));
    QCheckBox *lookAheadCheckBox = new QCheckBox(tr("Use lookahead"));
    lookAheadCheckBox->setChecked(true);

    QCheckBox *autoStopCheckBox = new QCheckBox(tr("Auto stop after games:"));
    QLineEdit *numGamesBox = new QLineEdit();

    QSlider *speedSlider = new QSlider(Qt::Horizontal, 0);
    speedSlider->setRange(0,100);
    speedSlider->setValue(100);


    QVBoxLayout *aiSelectorLayout = new QVBoxLayout;
    aiSelectorLayout->addWidget(noneRadio);
    aiSelectorLayout->addWidget(greedyRadio);
    aiSelectorLayout->addWidget(reinforcementRadio);
    aiSelectorLayout->addWidget(autoPlayCheckBox);
    aiSelectorLayout->addWidget(invisiblePlayCheckBox);
    aiSelectorLayout->addWidget(lineDownCheckBox);
    aiSelectorLayout->addWidget(lookAheadCheckBox);
    aiSelectorLayout->addWidget(autoStopCheckBox);
    aiSelectorLayout->addWidget(numGamesBox);
    aiSelectorLayout->addWidget(speedSlider);

    //vbox->addStretch(1);

    aiSelector->setLayout(aiSelectorLayout);

    //statistics box
    QGroupBox *aiStatistics = new QGroupBox(tr("Statistics"));
    QLabel *numGamesDescription = new QLabel(tr("Games played"));
    QLCDNumber *numGames = new QLCDNumber(7);
    QLabel *totalMovesDescription = new QLabel(tr("Total moves"));
    QLCDNumber *totalMoves = new QLCDNumber(7);
    QLabel *maxLinesRemovedDescription = new QLabel(tr("Maximum lines removed"));
    QLCDNumber *maxLinesRemoved = new QLCDNumber(7);
    QLabel *avgLinesRemovedDescription = new QLabel(tr("Average lines removed"));
    QLCDNumber *avgLinesRemoved = new QLCDNumber(7);
    QLabel *movingAvgLinesRemovedDescription = new QLabel(tr("Moving average lines removed"));
    QLCDNumber *movingAvgLinesRemoved = new QLCDNumber(7);
    QGridLayout *aiStatisticsLayout = new QGridLayout;

    aiStatisticsLayout->addWidget(numGamesDescription, 0, 0);
    aiStatisticsLayout->addWidget(numGames, 0, 1);
    aiStatisticsLayout->addWidget(totalMovesDescription, 1, 0);
    aiStatisticsLayout->addWidget(totalMoves, 1, 1);
    aiStatisticsLayout->addWidget(maxLinesRemovedDescription, 2, 0);
    aiStatisticsLayout->addWidget(maxLinesRemoved, 2, 1);
    aiStatisticsLayout->addWidget(avgLinesRemovedDescription, 3, 0);
    aiStatisticsLayout->addWidget(avgLinesRemoved, 3, 1);
    aiStatisticsLayout->addWidget(movingAvgLinesRemovedDescription, 4, 0);
    aiStatisticsLayout->addWidget(movingAvgLinesRemoved, 4, 1);

    aiStatistics->setLayout(aiStatisticsLayout);

    //parameter loader
    QLineEdit *paramView = new QLineEdit("test");
    paramView->setReadOnly(true);
    QLineEdit *paramEdit = new QLineEdit;
    QGridLayout *paramBox = new QGridLayout;
    paramBox->addWidget(paramView, 0, 0);
    paramBox->addWidget(paramEdit, 1, 0);

    //tetris
    connect(startButton, SIGNAL(clicked()), board, SLOT(start()));
    connect(quitButton , SIGNAL(clicked()), qApp, SLOT(quit()));
    connect(pauseButton, SIGNAL(toggled(bool)), board, SLOT(pause(bool)));
    //connect(board, SIGNAL(scoreChanged(int)), scoreLcd, SLOT(display(int)));
    connect(board, SIGNAL(levelChanged(int)), levelLcd, SLOT(display(int)));
    connect(board, SIGNAL(linesRemovedChanged(int)), linesLcd, SLOT(display(int)));

    //connect ai stuff
    connect(speedSlider, SIGNAL(valueChanged(int)), board, SLOT(setAISpeed(int)));
    connect(autoPlayCheckBox, SIGNAL(toggled(bool)), board, SLOT(setAutoPlay(bool)));
    connect(invisiblePlayCheckBox, SIGNAL(toggled(bool)), board, SLOT(setInvisiblePlay(bool)));
    connect(lookAheadCheckBox, SIGNAL(toggled(bool)), board, SLOT(setLookAheadEnabled(bool)));
    connect(lineDownCheckBox, SIGNAL(toggled(bool)), board, SLOT(setLineDownTimeoutEnabled(bool)));
    connect(autoStopCheckBox, SIGNAL(toggled(bool)), board, SLOT(setAutoStopEnabled(bool)));
    connect(numGamesBox, SIGNAL(textEdited(QString)), board, SLOT(setAutoStopGames(QString)));
    connect(board, SIGNAL(gamesPlayedChanged(int)), numGames, SLOT(display(int)));
    connect(board, SIGNAL(totalMovesChanged(int)), totalMoves, SLOT(display(int)));
    connect(board, SIGNAL(maxLinesRemovedChanged(int)), maxLinesRemoved, SLOT(display(int)));
    connect(board, SIGNAL(avgLinesRemovedChanged(double)), avgLinesRemoved, SLOT(display(double)));
    connect(board, SIGNAL(movingAvgLinesChanged(double)), movingAvgLinesRemoved, SLOT(display(double)));
    connect(board, SIGNAL(parametersChanged(QString)), paramView, SLOT(setText(QString)));
    connect(paramEdit, SIGNAL(textEdited(QString)), board, SLOT(setParameters(QString)));

    //connect ai selector
    connect(noneRadio, SIGNAL(toggled(bool)), board, SLOT(setNoAI(bool)));
    connect(reinforcementRadio, SIGNAL(toggled(bool)), board, SLOT(setZuckerAI(bool)));
    connect(greedyRadio, SIGNAL(toggled(bool)), board, SLOT(setGreedyAI(bool)));

    //tetris
    QGridLayout *tetrisLayout = new QGridLayout;
    tetrisLayout->addWidget(board, 0, 0, 11, 1);

    int y=0;
    tetrisLayout->addWidget(createLabel(tr("TIME ELAPSED")), y++, 1);
    tetrisLayout->addWidget(digitalClock, y++, 1);
    tetrisLayout->addWidget(createLabel(tr("LEVEL")), y++, 1);
    tetrisLayout->addWidget(levelLcd, y++, 1);
    tetrisLayout->addWidget(createLabel(tr("LINES")), y++, 1);
    tetrisLayout->addWidget(linesLcd, y++, 1);
    tetrisLayout->addWidget(createLabel(tr("NEXT")), y++, 1);
    const int nextPieceRow = y;
    tetrisLayout->addWidget(nextPieceLabel, y++, 1);
    tetrisLayout->addWidget(quitButton, y++, 1);
    tetrisLayout->addWidget(pauseButton, y++, 1);
    tetrisLayout->addWidget(startButton, y++, 1);
    tetrisLayout->setColumnStretch(0, 2);
    tetrisLayout->setColumnStretch(1, 1);
    tetrisLayout->setRowMinimumHeight(nextPieceRow, 100);

    //our ai stuff
    QGridLayout *AILayout = new QGridLayout;
    AILayout->addWidget(aiSelector, 1, 0);
    AILayout->addWidget(aiStatistics, 2, 0);

    //combine layouts
    QGridLayout *boxLayout = new QGridLayout;
    boxLayout->addLayout(tetrisLayout, 0, 0);
    boxLayout->setColumnStretch(0, 3);
    boxLayout->addLayout(AILayout, 0, 1);
    boxLayout->setColumnStretch(1, 1);
    boxLayout->addLayout(paramBox, 1, 0, 1, 2);

    setLayout(boxLayout);

    setWindowTitle(tr("Restit"));
    resize(768, 576);
}
示例#11
0
QLCDNumber * GameBoard::createLCD()
{
    QLCDNumber * LCD = new QLCDNumber(2);
    LCD->setSegmentStyle(QLCDNumber::Filled);
    return LCD;
}
示例#12
0
void WifiWidget::setupDisplay()
{
    const int numRowsPerInterface = 6; 
    const int numDigits = 4;
    
    QGridLayout *globalLayout = new QGridLayout(this);
    globalLayout->setColumnStretch(0,0);
    globalLayout->setColumnStretch(1,1);
    globalLayout->setColumnStretch(2,1);
    
    for (unsigned int i=0; i<numInterfaces_; i++)
    {
        QLabel *interfaceLabel = new QLabel;
        interfaceLabel->setFont(QFont("Helvetica", 12, QFont::Bold));
        globalLayout->addWidget(interfaceLabel,numRowsPerInterface*i,0);
        interfaceLabels_.push_back( interfaceLabel );
        
        QLabel *accessPointLabel = new QLabel;
        accessPointLabel->setFont(QFont("Helvetica", 12, QFont::Bold));
        globalLayout->addWidget(accessPointLabel,numRowsPerInterface*i,1);
        accessPointLabels_.push_back( accessPointLabel );
        
        QLCDNumber *lcdSignalLevel = new QLCDNumber(numDigits, this);
        lcdSignalLevel->setSegmentStyle(QLCDNumber::Filled);
        lcdsSignal_.push_back(lcdSignalLevel);
        QLCDNumber *lcdMaxSignalLevel = new QLCDNumber(numDigits, this);
        lcdMaxSignalLevel->setSegmentStyle(QLCDNumber::Filled);
        lcdsMaxSignal_.push_back(lcdMaxSignalLevel);
        QLabel *signalLabel = new QLabel("Signal: ");
        globalLayout->addWidget( signalLabel,numRowsPerInterface*i+1,0);
        globalLayout->addWidget( lcdSignalLevel,numRowsPerInterface*i+1,1);
        globalLayout->addWidget( lcdMaxSignalLevel,numRowsPerInterface*i+1,2);
        
        QLCDNumber *lcdNoiseLevel = new QLCDNumber(numDigits, this);
        lcdNoiseLevel->setSegmentStyle(QLCDNumber::Filled);
        lcdsNoise_.push_back(lcdNoiseLevel);
        QLCDNumber *lcdMaxNoiseLevel = new QLCDNumber(numDigits, this);
        lcdMaxNoiseLevel->setSegmentStyle(QLCDNumber::Filled);
        lcdsMaxNoise_.push_back(lcdMaxNoiseLevel);
        QLabel *noiseLabel = new QLabel("Noise: ");
        globalLayout->addWidget( noiseLabel,numRowsPerInterface*i+2,0);
        globalLayout->addWidget( lcdNoiseLevel,numRowsPerInterface*i+2,1);
        globalLayout->addWidget( lcdMaxNoiseLevel,numRowsPerInterface*i+2,2);
        
        QLCDNumber *lcdLinkLevel = new QLCDNumber(numDigits, this);
        lcdLinkLevel->setSegmentStyle(QLCDNumber::Filled);
        lcdsLink_.push_back(lcdLinkLevel);
        QLCDNumber *lcdMaxLinkLevel = new QLCDNumber(numDigits, this);
        lcdMaxLinkLevel->setSegmentStyle(QLCDNumber::Filled);
        lcdsMaxLink_.push_back(lcdMaxLinkLevel);
        QLabel *linkLabel = new QLabel("Link quality: ");
        globalLayout->addWidget( linkLabel,numRowsPerInterface*i+3,0);
        globalLayout->addWidget( lcdLinkLevel,numRowsPerInterface*i+3,1);
        globalLayout->addWidget( lcdMaxLinkLevel,numRowsPerInterface*i+3,2);
                
        QLCDNumber *lcdBitrate = new QLCDNumber(numDigits, this);
        lcdBitrate->setSegmentStyle(QLCDNumber::Filled);
        lcdsBitrate_.push_back(lcdBitrate);
        QLabel *bitRateLabel = new QLabel("Bit rate (Mb/s): ");
        globalLayout->addWidget( bitRateLabel,numRowsPerInterface*i+4,0);
        globalLayout->addWidget( lcdBitrate,numRowsPerInterface*i+4,1);
        
        QProgressBar *overall = new QProgressBar;
        overall->setMinimum(0);
        overall->setMaximum(MAXIMUM_SNR);
        progressBars_.push_back(overall);
        QLabel *progressLabel = new QLabel("Overall signal level: ");
        QLabel *overallSigLabel = new QLabel;
        overallSigLabel->setFont(QFont("Helvetica", 12, QFont::Bold));
        overallSigLabels_.push_back( overallSigLabel );
        globalLayout->addWidget( progressLabel,numRowsPerInterface*i+5,0);
        globalLayout->addWidget( overall,numRowsPerInterface*i+5,1);
        globalLayout->addWidget( overallSigLabel,numRowsPerInterface*i+5,2);
    }
    setLayout(globalLayout);
}