1. 程式人生 > >QSlider和QLCDNumber 滑塊 LCD

QSlider和QLCDNumber 滑塊 LCD

//LCD類和Qslider類


#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLCDNumber>
#include <QSlider>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QLCDNumber *lcd = new QLCDNumber(2,this);
    lcd->setGeometry(0,0,this->width(),this->height());
    QSlider *slider = new QSlider(Qt::Horizontal,this);
    slider->setRange(0,99);
    slider->setValue(0);
    slider->setGeometry(0,0,this->width(),20);
    QObject::connect(slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)));


}

MainWindow::~MainWindow()
{
    delete ui;
}